Skip to content

v2: fonts imported from css file are 404 if PUBLIC_URL=. #5162

@sylvhama

Description

@sylvhama

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

font, public_url

Environment

"react-scripts": "^2.0.1"

Steps to Reproduce

  1. Add font file with src
  2. Import this font file from a CSS file
  3. Import the CSS in your app (e.g. index.js)
  4. Create .env file and add it PUBLIC_URL=.
  5. Build and test

Expected Behavior

The font URL should be http://localhost:5000/static/media/Roboto-Regular.3e1af3ef.ttf
It was working perfectly with CRA v1.

Actual Behavior

The font URL is http://localhost:5000/static/css/static/media/Roboto-Regular.3e1af3ef.ttf

Reproducible Demo

I've created a repo to reproduce: https://github.com/sylvhama/cra2-font-bug

  1. git clone https://github.com/sylvhama/cra2-font-bug.git
  2. npm i
  3. npm run build
  4. serve -s build
  5. Open URL in browser, look at the console: Failed to decode downloaded font: http://localhost:5000/static/css/static/media/Roboto-Regular.3e1af3ef.ttf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions