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.

No 'Access-Control-Allow-Origin' header is present

See original GitHub issue

Hi

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
girichandu143commented, Aug 31, 2018

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() {}

}

4reactions
devtorocommented, Aug 9, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

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