0
0
Fork 0

Streaming: use standard cors package instead of custom implementation (#28523)

This commit is contained in:
Emelia Smith 2024-01-04 10:18:03 +01:00 committed by GitHub
parent 9c268c9413
commit 9826b7780a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 16 deletions

View file

@ -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);