No 'Access-Control-Allow-Origin' header is present
See original GitHub issueHi
I am creating a JS widget in rails and using the custom fonts in the widget css using @font-face.
but i am getting this error when i put my widget on another site
Access to Font at 'http://localhost:3000/assets/AvenirNextCyr/AvenirNextCyr-MediumItalic-774c88c40255e677b903e1719165c78eeb78d6c80902cf79c60bd79e3fc73542.otf' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin ‘null’ is therefore not allowed access.
Here is my configuration in application.rb
config.middleware.insert_before ActionDispatch::Static, Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [:get, :post, :options]
end
end
Please provide me a solution. Thanks in advance
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:21 (7 by maintainers)
Top Results From Across the Web
Reason: CORS header 'Access-Control-Allow-Origin' missing
The response to the CORS request is missing the required Access-Control-Allow-Origin header, which is used to determine whether or not the ...
Read more >Why does my JavaScript code receive a "No 'Access-Control ...
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I know that the API ...
Read more >3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >Resolve the "No 'Access-Control-Allow-Origin' header" error ...
Confirm the origin's cross-origin resource sharing (CORS) policy allows the origin to return the Access-Control-Allow-Origin header · Configure the CloudFront ...
Read more >How to resolve CORS policy: No 'Access-Control-Allow-Origin ...
can any one have idea this error. alt text. I am setting request headers as shown below. & angular is running in my...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
simple just create filter
public class CORSFilter implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { System.out.println(“Filtering on…”); HttpServletResponse response = (HttpServletResponse) res; response.setHeader(“Access-Control-Allow-Origin”, “*”); response.setHeader(“Access-Control-Allow-Methods”, “POST, GET, PUT, OPTIONS, DELETE”); response.setHeader(“Access-Control-Max-Age”, “3600”); response.setHeader(“Access-Control-Allow-Headers”, “X-requested-with, Content-Type”); chain.doFilter(req, res); } public void init(FilterConfig filterConfig) {} public void destroy() {}
}
I have similar issue after I updated to version 1.0.1. The version I was using before that was 0.4.1. I have an ember js application and the error I got was:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
I rolled back to 0.4.1 and everything is working again as expected.
Hope this helps to resolve this issue.