another cors config
This commit is contained in:
parent
39600a7646
commit
22d6302118
|
@ -10,6 +10,14 @@ import feedbackRouter from "./routers/feedback-router";
|
||||||
import paymentRouter from "./routers/payment-router";
|
import paymentRouter from "./routers/payment-router";
|
||||||
import dictionaryRouter from "./routers/dictionary-router";
|
import dictionaryRouter from "./routers/dictionary-router";
|
||||||
|
|
||||||
|
const sameOriginCorsOpts = {
|
||||||
|
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
||||||
|
credentials: true,
|
||||||
|
};
|
||||||
|
const openCorsOpts = {
|
||||||
|
origin: "*",
|
||||||
|
credentials: false,
|
||||||
|
};
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
// MIDDLEWARE AND SETUP 🔧 //
|
// MIDDLEWARE AND SETUP 🔧 //
|
||||||
|
@ -26,21 +34,14 @@ app.use(passport.session());
|
||||||
setupPassport(passport);
|
setupPassport(passport);
|
||||||
|
|
||||||
// Web Interface - returning html (mostly)
|
// Web Interface - returning html (mostly)
|
||||||
app.use(cors({
|
app.use("/", cors(sameOriginCorsOpts), authRouter(passport));
|
||||||
origin: inProd ? /\.lingdocs\.com$/ : "*",
|
|
||||||
credentials: true,
|
|
||||||
}));
|
|
||||||
app.use("/", authRouter(passport));
|
|
||||||
// REST API - returning json
|
// REST API - returning json
|
||||||
app.use("/api", apiRouter);
|
app.use("/api", cors(sameOriginCorsOpts), apiRouter);
|
||||||
app.use("/feedback", feedbackRouter);
|
app.use("/feedback", cors(sameOriginCorsOpts), feedbackRouter);
|
||||||
app.use("/payment", paymentRouter);
|
// TODO: check - does this work with the cors ?
|
||||||
app.use(cors({
|
app.use("/payment", cors(sameOriginCorsOpts), paymentRouter);
|
||||||
origin: "*", // inProd ? /\.lingdocs\.com$/ : "*",
|
|
||||||
credentials: false,
|
|
||||||
}));
|
|
||||||
// Dictionary API
|
// Dictionary API
|
||||||
app.use("/dictionary", dictionaryRouter)
|
app.use("/dictionary", cors(openCorsOpts), dictionaryRouter);
|
||||||
|
|
||||||
// START 💨 //
|
// START 💨 //
|
||||||
app.listen(4000, () => console.log("Server Has Started on 4000"));
|
app.listen(4000, () => console.log("Server Has Started on 4000"));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
POST https://account.lingdocs.com/dictionary/all-words HTTP/1.1
|
POST https://account.lingdocs.com/dictionary/script-to-phonetics HTTP/1.1
|
||||||
content-type: application/json
|
content-type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"word": "کور"
|
"text": "کور ته ځم",
|
||||||
|
"accents": false
|
||||||
}
|
}
|
Loading…
Reference in New Issue