Streaming: use standard cors package instead of custom implementation (#28523)
This commit is contained in:
parent
9c268c9413
commit
9826b7780a
3 changed files with 27 additions and 16 deletions
|
@ -5,6 +5,7 @@ const http = require('http');
|
|||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
const cors = require('cors');
|
||||
const dotenv = require('dotenv');
|
||||
const express = require('express');
|
||||
const Redis = require('ioredis');
|
||||
|
@ -187,6 +188,7 @@ const startServer = async () => {
|
|||
|
||||
const pgPool = new pg.Pool(pgConfigFromEnv(process.env));
|
||||
const server = http.createServer(app);
|
||||
app.use(cors());
|
||||
|
||||
/**
|
||||
* @type {Object.<string, Array.<function(Object<string, any>): void>>}
|
||||
|
@ -327,19 +329,6 @@ const startServer = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} req
|
||||
* @param {any} res
|
||||
* @param {function(Error=): void} next
|
||||
*/
|
||||
const allowCrossDomain = (req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Headers', 'Authorization, Accept, Cache-Control');
|
||||
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} req
|
||||
* @param {any} res
|
||||
|
@ -987,7 +976,6 @@ const startServer = async () => {
|
|||
|
||||
api.use(setRequestId);
|
||||
api.use(setRemoteAddress);
|
||||
api.use(allowCrossDomain);
|
||||
|
||||
api.use(authenticationMiddleware);
|
||||
api.use(errorMiddleware);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"check:types": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"ioredis": "^5.3.2",
|
||||
|
@ -28,6 +29,7 @@
|
|||
"ws": "^8.12.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.16",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/npmlog": "^7.0.0",
|
||||
"@types/pg": "^8.6.6",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue