Fix CORS
This commit is contained in:
8
index.js
8
index.js
@@ -7,6 +7,12 @@ const middlewares = jsonServer.defaults();
|
|||||||
|
|
||||||
server.use(middlewares);
|
server.use(middlewares);
|
||||||
|
|
||||||
|
server.use((req, res, next) => {
|
||||||
|
res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from
|
||||||
|
res.header("Referrer-Policy", "same-origin");
|
||||||
|
next();
|
||||||
|
})
|
||||||
|
|
||||||
server.get("/orderStatuses", (req, res, next) => {
|
server.get("/orderStatuses", (req, res, next) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
next();
|
next();
|
||||||
@@ -38,4 +44,4 @@ server.use(router);
|
|||||||
const port = process.env.PORT || 3000
|
const port = process.env.PORT || 3000
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
console.log(`JSON Server is running on port ${port}`);
|
console.log(`JSON Server is running on port ${port}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user