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

Ktor Server CORS Feature - Pattern matching for origin #1989

Closed
coud opened this issue Jul 2, 2020 · 6 comments
Closed

Ktor Server CORS Feature - Pattern matching for origin #1989

coud opened this issue Jul 2, 2020 · 6 comments

Comments

@coud
Copy link

coud commented Jul 2, 2020

Subsystem
Server

Is your feature request related to a problem? Please describe.
I stumbled upon a problem where I need to allow origin by wildcard or pattern, ex. http://*.example.com so any subdomain is allowed.

Describe the solution you'd like
I want to be able to specify a host with a pattern matching like regex or glob style or give us a way to set a custom callback for checking the origin

Motivation to include to ktor
There is no way to solve this with the current CORS feature.

@coud coud added the feature label Jul 2, 2020
@Ololoshechkin
Copy link
Contributor

Thanks for the feature request! I believe this can be done and we'll try to work on that

@oleg-larshin
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@OlafurBJonsson
Copy link

Is there any update on this or at least some method of going about this. I've tried overriding/extending the class but unable as it is set to final.

@AndrewWestberg
Copy link

Is there any information on using the fix in 1.6.5? Do we set subdomains to "", or maybe just put the wildcard in the hosts value ".domain.com"?

@Stexxe Stexxe closed this as completed Feb 8, 2022
@kavithareddyedula
Copy link

please add some examples to use it .I tried with full domain name . still no luck
allowHost("localhost:3000")
allowHost("xyz.xyz.com", schemes = listOf("http", "https"))

@coud
Copy link
Author

coud commented Jun 15, 2023

@kavithareddyedula
It's not documented on web but it has been possible to prefix * for wildcard subdomains. This is documented in allowHost source code.

please add some examples to use it .I tried with full domain name . still no luck allowHost("localhost:3000") allowHost("xyz.xyz.com", schemes = listOf("http", "https"))

allowHost("*.xyz.com", listOf("http", "https"))

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

No branches or pull requests

7 participants