How do I get the Origin request header from cross-domain AJAX requests in Rails?

有帮助吗?

解决方案

You can achieve this in the controller by using:

request.headers['origin']

Note: You will need to make certain changes in certain config files for your application to be able to respond to a CORS request. Hope you've got that covered.

其他提示

It seems like request.origin also works directly in recent rails versions. (at least Rails 6)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top