cors tweak
This commit is contained in:
parent
65b38085f0
commit
ada2c3d706
|
@ -11,26 +11,27 @@ import paymentRouter from "./routers/payment-router";
|
||||||
import dictionaryRouter from "./routers/dictionary-router";
|
import dictionaryRouter from "./routers/dictionary-router";
|
||||||
|
|
||||||
const sameOriginCorsOpts = {
|
const sameOriginCorsOpts = {
|
||||||
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
||||||
credentials: true,
|
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
|
||||||
|
credentials: true,
|
||||||
};
|
};
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
// MIDDLEWARE AND SETUP 🔧 //
|
// MIDDLEWARE AND SETUP 🔧 //
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
app.use("/payment/webhook", express.raw({type: "*/*"}));
|
app.use("/payment/webhook", express.raw({ type: "*/*" }));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(express.static("public"));
|
app.use(express.static("public"));
|
||||||
|
|
||||||
if (inProd) app.set('trust proxy', 1);
|
if (inProd) app.set("trust proxy", 1);
|
||||||
setupSession(app);
|
setupSession(app);
|
||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
app.use(passport.session());
|
app.use(passport.session());
|
||||||
setupPassport(passport);
|
setupPassport(passport);
|
||||||
|
|
||||||
app.get("/test", cors(), (req, res) => {
|
app.get("/test", cors(), (req, res) => {
|
||||||
res.send({ ok: true });
|
res.send({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dictionary API
|
// Dictionary API
|
||||||
|
@ -39,12 +40,11 @@ app.use("/dictionary", cors(), dictionaryRouter);
|
||||||
|
|
||||||
// Web Interface - returning html (mostly)
|
// Web Interface - returning html (mostly)
|
||||||
app.use("/", cors(sameOriginCorsOpts), authRouter(passport));
|
app.use("/", cors(sameOriginCorsOpts), authRouter(passport));
|
||||||
// REST API - returning json
|
// REST API - returning json
|
||||||
app.use("/api", cors(sameOriginCorsOpts), apiRouter);
|
app.use("/api", cors(sameOriginCorsOpts), apiRouter);
|
||||||
app.use("/feedback", cors(sameOriginCorsOpts), feedbackRouter);
|
app.use("/feedback", cors(sameOriginCorsOpts), feedbackRouter);
|
||||||
// TODO: check - does this work with the cors ?
|
// TODO: check - does this work with the cors ?
|
||||||
app.use("/payment", cors(sameOriginCorsOpts), paymentRouter);
|
app.use("/payment", cors(sameOriginCorsOpts), paymentRouter);
|
||||||
|
|
||||||
|
|
||||||
// START 💨 //
|
// START 💨 //
|
||||||
app.listen(4000, () => console.log("Server Has Started on 4000"));
|
app.listen(4000, () => console.log("Server Has Started on 4000"));
|
||||||
|
|
Loading…
Reference in New Issue