سؤال

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