fix(cors): enable preflight for Capacitor WebView requests
Add express cors middleware with reflected origin so Android clients from https://localhost receive Access-Control-Allow-* headers on OPTIONS and can proceed with POST requests.
This commit is contained in:
3796
package-lock.json
generated
Normal file
3796
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,12 +12,14 @@
|
|||||||
"@peculiar/asn1-ecc": "^2.3.8",
|
"@peculiar/asn1-ecc": "^2.3.8",
|
||||||
"@peculiar/asn1-schema": "^2.3.8",
|
"@peculiar/asn1-schema": "^2.3.8",
|
||||||
"cbor-x": "^1.5.9",
|
"cbor-x": "^1.5.9",
|
||||||
|
"cors": "^2.8.6",
|
||||||
"did-jwt": "^7.4.7",
|
"did-jwt": "^7.4.7",
|
||||||
"did-resolver": "^4.1.0",
|
"did-resolver": "^4.1.0",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"firebase-admin": "^13.9.0"
|
"firebase-admin": "^13.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.0",
|
||||||
"@types/node": "^22.10.0",
|
"@types/node": "^22.10.0",
|
||||||
"tsx": "^4.19.2",
|
"tsx": "^4.19.2",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import cors from "cors";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import "./services/firebase.js";
|
import "./services/firebase.js";
|
||||||
import { debugRouter } from "./routes/debug.js";
|
import { debugRouter } from "./routes/debug.js";
|
||||||
@@ -7,6 +8,14 @@ import { startScheduler } from "./scheduler.js";
|
|||||||
const app = express();
|
const app = express();
|
||||||
const port = Number(process.env.PORT) || 3000;
|
const port = Number(process.env.PORT) || 3000;
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
cors({
|
||||||
|
origin: true,
|
||||||
|
methods: ["GET", "POST", "OPTIONS"],
|
||||||
|
allowedHeaders: ["Content-Type", "Authorization"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
// Keep stable for diagnostics tooling compatibility
|
// Keep stable for diagnostics tooling compatibility
|
||||||
|
|||||||
Reference in New Issue
Block a user