Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 6b4ed84

Browse files
committed
middleware remved for host not match (origin undefined) issue
now deployments have web token security, all other endpoints are secured by https
1 parent 84053c6 commit 6b4ed84

File tree

2 files changed

+25
-50
lines changed

2 files changed

+25
-50
lines changed

app.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,25 @@ connect.then(
6262
}
6363
);
6464

65-
app.use('/', indexRouter);
65+
6666
app.use("/", adminRouter);
6767
app.use("/", afterDeploymentRouter);
68-
app.use(
69-
"/graphql",
70-
graphqlHTTP({
71-
schema: schema,
72-
graphiql: true,
73-
})
74-
);
75-
const headerMiddleware = require("./middlewares/HeaderMiddleware");
76-
app.use(headerMiddleware);
68+
69+
app.use((req, res, next) => {
70+
res.setHeader("Access-Control-Allow-Origin", "*");
71+
res.setHeader(
72+
"Access-Control-Allow-Methods",
73+
"OPTIONS, GET, POST, PUT, PATCH, DELETE"
74+
);
75+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
76+
77+
if (req.method === "OPTIONS") {
78+
return res.sendStatus(200);
79+
}
80+
next();
81+
});
82+
83+
app.use('/', indexRouter);
7784
app.use("/", listenerRouter);
7885
app.use("/", tokensListRouter);
7986
app.use("/", deploypairRouter);
@@ -86,6 +93,14 @@ app.use("/", pathRouter);
8693
app.use("/", readWasmRouter);
8794
app.use("/", setUserForRemoveLiquidityCSPRRouter);
8895

96+
app.use(
97+
"/graphql",
98+
graphqlHTTP({
99+
schema: schema,
100+
graphiql: true,
101+
})
102+
);
103+
89104
// catch 404 and forward to error handler
90105
app.use(function (req, res, next) {
91106
next(createError(404));

middlewares/HeaderMiddleware.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)