mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-22 21:45:56 +03:00
cors: adding cors middleware to express
This commit is contained in:
parent
60a23a87e3
commit
8ed70e615c
@ -51,6 +51,7 @@
|
||||
"chart.js": "^2.9.3",
|
||||
"chartkick": "^3.2.0",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
|
@ -9,6 +9,7 @@ import * as AnalyticsManager from "~/node_common/managers/analytics";
|
||||
import express from "express";
|
||||
import next from "next";
|
||||
import compression from "compression";
|
||||
import cors from "cors";
|
||||
|
||||
const app = next({
|
||||
dev: !Environment.IS_PRODUCTION,
|
||||
@ -21,6 +22,8 @@ const handler = app.getRequestHandler();
|
||||
app.prepare().then(async () => {
|
||||
const server = express();
|
||||
|
||||
app.use(cors());
|
||||
|
||||
if (Environment.IS_PRODUCTION) {
|
||||
server.use(compression());
|
||||
}
|
||||
@ -119,7 +122,9 @@ app.prepare().then(async () => {
|
||||
}
|
||||
|
||||
return app.render(req, res, "/_/slate", {
|
||||
slate: JSON.parse(JSON.stringify({ ...slate, ownername: req.params.username })),
|
||||
slate: JSON.parse(
|
||||
JSON.stringify({ ...slate, ownername: req.params.username })
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user