-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
[BUG] Access-Control-Allow-Origin returns empty string when origin is set to url string #41
Comments
I experienced this a while back and it was user error not not Elyisia. I don't remember what was the problem. Maybe credentials? |
Any solution to this? i tried setting a regex and i tried just a string with |
Yea this has taken me 2 days to notice that the headers are actually being set to ''; --- EDIT --- Just noticed from issue #5 |
Any one have figured out this particular issue? |
The workaround: remove protocol from the const app = new Elysia()
.use(cors({
origin: 'localhost:5173' // this works, but allows all protocols
}))
.get('/', () => {
return 'Oh hi!'
}) Root cause: For reference, I would go with comparing request origin with allowed origin as is. @SaltyAom if you approve solution, I can raise a PR 🙏 |
Very nuanced bug, either we update documentation with examples or fix it to follow other implementations. |
same issue here this is really annoying. |
Worked fine for me, really strange problem btw |
Updating to 1.0.4 should fix the problem. |
works for me |
Doesn't work again whether I add the protocol or not on cloudflare workers version 1.1.0 |
Now I'm using a additional hook to solve this app.onRequest(({ set }) => {
set.headers['access-control-allow-credentials'] = 'true'
}) |
Sample use case, considering we want to limit origin to a specific client app url. One would use cors plugin like the following:
Expected to have
Access-Control-Allow-Origin
equal to the app url which ishttp://localhost:5173
. But the cors plugin returns empty string instead:The text was updated successfully, but these errors were encountered: