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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue