Skip to content
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

Skip cors headers if domain not matching #1103

Open
vojkny opened this issue May 1, 2024 · 0 comments
Open

Skip cors headers if domain not matching #1103

vojkny opened this issue May 1, 2024 · 0 comments

Comments

@vojkny
Copy link
Contributor

vojkny commented May 1, 2024

I am adding cors as follows:

private val corsPolicy = CorsPolicy(
    originPolicy = OriginPolicy.AnyOf(systemEnv("ORIGIN_POLICY").split(",")),
    headers = listOf("*"),
    methods = Method.entries,
)

val corsFilter = Cors(corsPolicy)

This works for matching domains:

< Access-Control-Allow-Origin: my-domain.com
< Access-Control-Allow-Headers: *
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, TRACE, PATCH, PURGE, HEAD

But for not matching domains, it ends up like this:

< Access-Control-Allow-Origin: null
< Access-Control-Allow-Headers: *
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, TRACE, PATCH, PURGE, HEAD

Wouldn't it be better to completely skip adding these headers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant