🚒 Trying out nginx for CORS mitigation

This commit is contained in:
2021-11-24 23:15:56 -08:00
parent 25d68edbc4
commit 95fe37e542
5 changed files with 42 additions and 50 deletions

View File

@@ -2,11 +2,9 @@ import express, { Request, Response, Router, Express } from "express";
import bodyParser from "body-parser";
import router from "./route";
import path from "path";
import cors_proxy from "cors-anywhere";
// call express
const app: Express = express(); // define our app using express
const host = process.env.HOST || "0.0.0.0";
// configure app to use bodyParser for
// Getting data from body of requests
@@ -29,20 +27,6 @@ app.use("/api", routes);
app.use(express.static("dist"));
app.use(express.static("public"));
// app.listen(port);
// console.log(`Server is listening on ${port}`);
app.listen(port);
cors_proxy
.createServer({
originWhitelist: [], // Allow all origins
requireHeader: ["origin", "x-requested-with"],
removeHeaders: ["cookie", "cookie2"],
})
.listen(port, host, function () {
console.log(
"ThreeTwo! Express server with CORS Anywhere running on " +
host +
":" +
port,
);
});
console.log(`Server is listening on ${port}`);