Enable cors

This commit is contained in:
Yarmo Mackenbach 2022-11-14 19:00:02 +01:00
parent 50b3254c7d
commit da57f4c57d
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1
3 changed files with 6 additions and 2 deletions

View file

@ -8,6 +8,7 @@
"ajv": "^8.6.3", "ajv": "^8.6.3",
"bent": "^7.3.12", "bent": "^7.3.12",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"cors": "^2.8.5",
"dialog-polyfill": "^0.5.6", "dialog-polyfill": "^0.5.6",
"doipjs": "^0.17.2", "doipjs": "^0.17.2",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",

View file

@ -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 <https://www.gnu.org/licenses/>. more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
*/ */
import express from 'express' import express from 'express'
import cors from 'cors'
import { readFileSync } from 'fs' import { readFileSync } from 'fs'
import { stringReplace } from 'string-replace-middleware' import { stringReplace } from 'string-replace-middleware'
import * as pug from 'pug' import * as pug from 'pug'
@ -42,6 +43,8 @@ import utilRoute from '../routes/util.js'
const app = express() const app = express()
const packageData = JSON.parse(readFileSync('./package.json')) const packageData = JSON.parse(readFileSync('./package.json'))
app.use(cors())
app.set('env', process.env.NODE_ENV || 'production') app.set('env', process.env.NODE_ENV || 'production')
app.engine('pug', pug.__express).set('view engine', 'pug') app.engine('pug', pug.__express).set('view engine', 'pug')
app.set('port', process.env.PORT || 3000) app.set('port', process.env.PORT || 3000)
@ -63,7 +66,7 @@ if (app.get('onion_url')) {
} }
app.use(stringReplace({ 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/, contentTypeFilterRegexp: /application\/javascript/,
})) }))

View file

@ -1569,7 +1569,7 @@ core-js@^3.22.1:
cors@^2.8.5: cors@^2.8.5:
version "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== integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
dependencies: dependencies:
object-assign "^4" object-assign "^4"