allow port in cors

This commit is contained in:
2026-02-26 14:31:16 +01:00
parent fd13b21329
commit 50b9b13c5d

View File

@@ -322,13 +322,16 @@ apxtri.runexpress = async (tribesdns, conf) => {
regtxt += ")$";
// let cor = false;whatwg-url
const regorigin = new RegExp(regtxt);
const allowedOrigins = [
'http://dev.smatchit.io:8081',
];
app.use(cors({
origin: function (origin, callback) {
if (!origin) {
return callback(null, true);
}
if (regorigin.test(origin)) {
if (regorigin.test(origin) || allowedOrigins.includes(origin)) {
return callback(null, true);
} else {
console.log(
@@ -346,7 +349,7 @@ apxtri.runexpress = async (tribesdns, conf) => {
app.use((req, res, next) => {
const origin = req.headers.origin;
if (origin && !regorigin.test(origin)) {
if (origin && !regorigin.test(origin) && !allowedOrigins.includes(origin)) {
console.log(`CORS blocked: ${origin}`);
return res.status(403).json({ error: 'CORS not allowed', origin });
}