-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow CORS from loopback addresses by default #19249
fix: allow CORS from loopback addresses by default #19249
Conversation
@sapphi-red, thoughts on supporting the popular |
I guess we can add |
@@ -161,7 +161,7 @@ export default defineConfig({ | |||
## server.cors | |||
|
|||
- **Type:** `boolean | CorsOptions` | |||
- **Default:** `false` | |||
- **Default:** `{ origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/ }` (allows localhost, `127.0.0.1` and `::1`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can also show that you can use defaultAllowedOrigins
here so users don't copy the regex as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expose defaultAllowedOrigins
so it's not possible to import it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah didn't notice that. I think it'd be useful to expose it, but we can do that in a later PR.
@timacdonald This PR has been released in 6.0.11, 5.4.14, 4.5.9. We didn't include
|
Appreciate your work and help here. We will add |
Description
Allow CORS from the following origins by default for convenience.
localhost
, domains of.localhost
127.0.0.1
::1
Technically, other addresses in
127.0.0/8
are also loopback addresses and safe to be allowed. But I didn't include them as it's not popular and makes the regex complicated.refs #19239