This time, we’ll introduce how to configure Allow-Control-Allow-Origin: * in Chrome extensions.
{/* “Allow-Control-Allow-Origin: *” extension configuration. */}
Allow-Control-Allow-Origin: * extension configuration.
:///* ://localhost:3000/
Also, for localhost, you need to add Access-Control-Allow-Origin:* to the http header,
and also add it to the extension’s Expose-header.
To add http header in Rails, write the following in the Controller corresponding to the view:
response.set_header('Access-Control-Allow-Origin', '*')
By adding the http header as above,
you can use the Allow-Control-Allow-Origin: * extension even for localhost.
Also, in the case of Rails, you can add the http header to all Controllers by writing the following in config/application.rb:
config.action_dispatch.default_headers = {
'Access-Control-Allow-Origin' => '*'
}
That’s all.