Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No 'Access-Control-Allow-Origin' header is present on the requested resource. when accessing from localhost #6987

Open
ianlintw opened this issue Jun 10, 2020 · 4 comments

Comments

@ianlintw
Copy link

Hi,

I am just starting to try out Semantic UI in my react project on a localhost machine. I add a CDN link of semantic.min.css as , but my browser complains that when it is trying to fetch icons.woff, icons.woff2, and icons.ttf it is blocked by CORS policy. It looks like the server hosting the resource needs to send out 'Access-Control-Allow-Origin' header, based on what I see in the browser console. Thoughts? Thanks in advance!

Best,
Ian


Here are the full error message:
Access to font at 'https://fonts.gstatic.com/s/lato/v16/S6uyw4BMUTPHjx4wXiWtFCc.woff2' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field accept-language is not allowed by Access-Control-Allow-Headers in preflight response.
localhost/:1 GET https://fonts.gstatic.com/s/lato/v16/S6uyw4BMUTPHjx4wXiWtFCc.woff2 net::ERR_FAILED
localhost/:1 Access to font at 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.woff2' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost/:1 GET https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.woff2 net::ERR_FAILED
localhost/:1 Access to font at 'https://fonts.gstatic.com/s/lato/v16/S6u9w4BMUTPHh6UVSwiPGQ3q5d0.woff2' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field accept-language is not allowed by Access-Control-Allow-Headers in preflight response.
localhost/:1 GET https://fonts.gstatic.com/s/lato/v16/S6u9w4BMUTPHh6UVSwiPGQ3q5d0.woff2 net::ERR_FAILED
localhost/:1 Access to font at 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.woff' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost/:1 GET https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.woff net::ERR_FAILED
localhost/:1 Access to font at 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.ttf' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost/:1 GET https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.ttf net::ERR_FAILED

@gilbertoalbino
Copy link

Same problem here.

I am using:

<link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"
    />

and the icons show a square box.

The console logs:

Access to font at 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.ttf' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost/:1 GET https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/themes/default/assets/fonts/icons.ttf net::ERR_FAILED

I am developing on Localhost.

@niazangels
Copy link

niazangels commented Jul 25, 2020

@ianlintw @gilbertoalbino By any chance do you guys have Location Override turned on? I turned it off and things started to work.
Seems like some sort of CDN rules are in place - switching to jsdeliver CDN (https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css) did not help either until I turned it off.

@gilbertoalbino
Copy link

@niazangels thanks!
I indeed had Location Override turned on!
I turned it off and it did the trick.
The problem is that I must use it on since I'm working on a project that demands switching countries this way.
But to solve it on development, I downloaded the assets and fonts into the project.

@gihan9a
Copy link

gihan9a commented Mar 10, 2021

Seems Google Chrome's locale override for location feature doesn't accept.

By default, it uses en_US for "San Fransisco" and leads to CORS error. When I override the local to en-US then it starts working with location override.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants