Skip to content

Access to font at has been blocked by CORS policy. #32069

Answered by mattcarlotta
Maxet24 asked this question in Help
Discussion options

You must be logged in to vote

@Maxet24 Remove relative imports to public and instead request public assets via the base URL / which utilizes public static file serving.

Working repo: https://github.com/mattcarlotta/crazy-suit-cases-fork
Working demo: https://crazy-suit-cases-fork.vercel.app/

Changes made:
pages/_document.js (optional -> preload fonts to reduce FOUC)
pages/index.js (invalid nesting -> p cannot be a descendant of p)
styles/global.css (request assets from public by utilizing the base URL /)

On that note, if you're trying to utilize assets across different domains, then this can be considered anti-pattern. Instead, you'll want to use a CDN. There are ways around it, like adding CORS to a Next project, but…

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Maxet24
Comment options

Answer selected by Maxet24
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Issue was opened via the bug report template.
6 participants
Converted from issue

This discussion was converted from issue #31870 on December 03, 2021 00:19.