-
Notifications
You must be signed in to change notification settings - Fork 55
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
Domain is blocked by CORS even though it is in the origin string? #73
Comments
I think you need to include the port. fastify.register(require('fastify-cors'), {
origin: 'http://modfi-dev.nonset.com:4000'
}) |
I've tried that as well, I see the same issue, it seems like it's looking for an exact match:
|
From docs, it is intended https://github.com/fastify/fastify-cors#options string: strict match |
Thanks for the response, the documentation made it sound like the context of the string match will match the domain name. Regex is still throwing issues:
The regex I am trying:
I also tried getting more aggressive but it still ending up with a 'false' result
Seems to match fine when testing here: https://regex101.com/ |
I would start from a playground like this since it seems to work:
The second one will print:
|
I don't understand: where did you set Here should work:
Note that In the worse scenario you can try the function:
|
localhost vs. 127.0.0.1 |
As I know combining '*' with credentials is bad, so it will not work, but I checked everything, like your suggestion, without credentials, with localhost, with 127.0.0.1, and so on. In postman, everything works fine, but when I try to make a call from frontend, nothing works |
I also tried it, and no success |
Hopefully a quick question from incorrect syntax. I am trying to only allow requests that are from my domain to succeed with fastify-cors. Requests are succeeding if I use an asterisk in the config but if I try and get specific on the domain it is failing.
This is the origin config I am trying to use:
However when I use Firefox to initiate a request to my App I am getting this CORS error:
I've tried adding the port as well as trying a regex expression for the origin config but it doesn't seem to make a difference.
This is how I am attempting to make the request to the fastify server from my app
appDomain is modfi-dev.nonset.com
Requests go through fine if I use an asterisk but that defeats the purpose of CORS:
Am I missing something obvious?
The text was updated successfully, but these errors were encountered: