Replies: 2 comments 2 replies
-
Had to use https://www.npmjs.com/package/patch-package to remove this temporarily. Feels bad to not have cors for dynamic imports, but it's acceptable. How did you bypass it @foloinfo |
Beta Was this translation helpful? Give feedback.
-
For those using PNPM, here is a drop-in patch to fix this: --- a/build/src/start/server/middleware/CorsMiddleware.js
+++ b/build/src/start/server/middleware/CorsMiddleware.js
@@ -14,7 +14,9 @@ const DEFAULT_ALLOWED_CORS_HOSTNAMES = [
function createCorsMiddleware(exp) {
var ref, ref1, ref2, ref3;
const allowedHostnames = [
- ...DEFAULT_ALLOWED_CORS_HOSTNAMES
+ ...DEFAULT_ALLOWED_CORS_HOSTNAMES,
+ // allow end-user to add more host names from an environment variable
+ ...(process.env.EXPO_CORS_ALLOWED_HOSTNAMES ? process.env.EXPO_CORS_ALLOWED_HOSTNAMES.split(",") : [])
];
// Support for expo-router API routes
if ((ref = exp.extra) == null ? void 0 : (ref1 = ref.router) == null ? void 0 : ref1.headOrigin) {
Update your {
...,
"pnpm": {
"patchedDependencies": {
"@expo/cli": "patches/@expo__cli.patch"
}
},
...
} Update your EXPO_CORS_ALLOWED_HOSTNAMES=my-pc.local,192.168.1.123 Finally, run {
"scripts": {
"start": "EXPO_CORS_ALLOWED_HOSTNAMES=my-pc.local,192.168.1.123 expo start -c"
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi, I was trying expo/router for my new project.
I found that
remoteDevtoolsSecurityHeadersMiddleware
disallows access from non-localhost (like local ip address 192.168.1.2).Is it possible to give some option to bypass this check?
@expo/dev-server/build/middleware/remoteDevtoolsSecurityHeadersMiddleware.js
Beta Was this translation helpful? Give feedback.
All reactions