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

CORS error is thrown when load fonts by using fontLocal #59813

Open
1 task done
illiakovalenko opened this issue Dec 20, 2023 · 1 comment
Open
1 task done

CORS error is thrown when load fonts by using fontLocal #59813

illiakovalenko opened this issue Dec 20, 2023 · 1 comment
Labels
bug Issue was opened via the bug report template. Font (next/font) Related to Next.js Font Optimization. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@illiakovalenko
Copy link

illiakovalenko commented Dec 20, 2023

Link to the code that reproduces this issue

Codesandbox solution

To Reproduce

  1. Introduce layout that uses localFont
  2. Set Access-Control-Allow-Origin header and set an origin where you are trying to render your nextjs app (https://codesandbox.io/p/devbox/hungry-tharp-y47qpv?file=%2Fnext.config.js%3A6%2C8)
  3. Apply font-family style (https://codesandbox.io/p/devbox/hungry-tharp-y47qpv?file=%2Fpages%2F%5B%5B...path%5D%5D.tsx%3A15%2C7)
  4. Start app using "next build" && "next start"
  5. Render a home page in a different origin (can be rendered by using api route, as an example)
  6. Open network tab and check request for .woff2 file

Current vs. Expected behavior

Following the steps from the previous section.

Current behavior
The font is not loaded, so it's not applied. CORS error is thrown
image
image
image

Expected behavior
The font is loaded successfully

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.5-canary.18
  eslint-config-next: 13.5.6
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 4.9.4
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Font optimization (next/font), Middleware / Edge (API routes, runtime)

Additional context

The first build that introduced the bug is 13.4.13-canary.0, since reverting it to 13.4.12 works.
Seems like it's related to another issue that I created: #59766
I shared the same playground, there are no differences

@illiakovalenko illiakovalenko added the bug Issue was opened via the bug report template. label Dec 20, 2023
@github-actions github-actions bot added Runtime Related to Node.js or Edge Runtime with Next.js. Font (next/font) Related to Next.js Font Optimization. labels Dec 20, 2023
@mg-aceik

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Font (next/font) Related to Next.js Font Optimization. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants
@illiakovalenko @mg-aceik and others