question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set Origin header to the request Origin

See original GitHub issue

I want to allow every Origin to use my API, but it seems I can’t do it with the * sign, cause I need to authorize on it, which ends up telling me the following: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true.

So how do I dynamically just send the origin to the request origin?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
szpasztorcommented, Jul 18, 2017

It doesn’t seem to accept the lambda as of version 1.0.0. This is what worked for me:

origins do |source, env|
    true
end

This proc evaluates the given source, always accepting it, and returning the request origin.

1reaction
cyucommented, Feb 28, 2016

Origin can be a proc, so something like this should work:

allow do
  origins ->(origin, env) { origin }
end
Read more comments on GitHub >

github_iconTop Results From Across the Web

Origin - HTTP - MDN Web Docs
The Origin request header indicates the origin (scheme, hostname, and port) that caused the request. For example, if a user agent needs to ......
Read more >
How to set the Origin Request Header - Stack Overflow
In short: you cannot. As described on MDN; Origin is a 'forbidden' header, meaning that you cannot change it programatically.
Read more >
origin-header in cors - liveBook · Manning
The Origin header is always present on cross-origin requests, and the client has no way of setting or overriding the value. This is...
Read more >
Adding custom headers to origin requests - Amazon CloudFront
You can configure CloudFront to add custom headers to the requests that it sends to your origin. These custom headers enable you to...
Read more >
CORS and the Access-Control-Allow-Origin response header
The CORS specification identifies a collection of protocol headers of which Access-Control-Allow-Origin is the most significant. This header is returned by a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found