From da57f4c57ddd341ec0e690567f7556aade1daadf Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 14 Nov 2022 19:00:02 +0100 Subject: [PATCH] Enable cors --- package.json | 1 + src/index.js | 5 ++++- yarn.lock | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 83e4cc0..5b99fbf 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "ajv": "^8.6.3", "bent": "^7.3.12", "body-parser": "^1.19.0", + "cors": "^2.8.5", "dialog-polyfill": "^0.5.6", "doipjs": "^0.17.2", "dotenv": "^8.2.0", diff --git a/src/index.js b/src/index.js index 821f0c6..fc88b04 100644 --- a/src/index.js +++ b/src/index.js @@ -28,6 +28,7 @@ if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . */ import express from 'express' +import cors from 'cors' import { readFileSync } from 'fs' import { stringReplace } from 'string-replace-middleware' import * as pug from 'pug' @@ -42,6 +43,8 @@ import utilRoute from '../routes/util.js' const app = express() const packageData = JSON.parse(readFileSync('./package.json')) +app.use(cors()) + app.set('env', process.env.NODE_ENV || 'production') app.engine('pug', pug.__express).set('view engine', 'pug') app.set('port', process.env.PORT || 3000) @@ -63,7 +66,7 @@ if (app.get('onion_url')) { } app.use(stringReplace({ - PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || 'null' + PLACEHOLDER__PROXY_HOSTNAME: process.env.PROXY_HOSTNAME || process.env.DOMAIN || 'null' }, { contentTypeFilterRegexp: /application\/javascript/, })) diff --git a/yarn.lock b/yarn.lock index fe64a1b..0f8d49c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1569,7 +1569,7 @@ core-js@^3.22.1: cors@^2.8.5: version "2.8.5" - resolved "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== dependencies: object-assign "^4"