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.

PUBLIC_URL is not the same as homepage, but only the pathname

See original GitHub issue

Describe the bug

I have uploaded all the static resources to CDN, include .js and .css files. So I have to set the ‘homepage’ as the host address of CDN server, which make the urls of scripts in ‘index.html’ to be right.

However, the urls injected to ‘index.html’ is the pathname of ‘homepage’ that I set in package.json, after upload react-scripts to 3.4.1.

And there is no such problem when I using version 3.3.0. I found that the actual homepage has been change after this PR feat(react-scripts): allow PUBLIC_URL in develoment mode

So I want to know, is it a bug that will be fixed? Or is there any method that can make the PUBLIC_URL to be a complete url.

Did you try recovering your dependencies?

no, but downgrade to 3.3.0

Which terms did you search for in User Guide?

The docs still use the complete url as example Step 1: Add homepage to package.json

Environment

irrelevant, i guess

Steps to reproduce

(Write your steps here:)

  1. set homepage in package.json like ‘https://example.com/a/b/c
  2. yarn build
  3. the url of script in index.html will be ‘/a/b/c/xxx.js’, which will not find the correct resource

Expected behavior

The PUBLIC_URL should be the same as homepage in package.json

Actual behavior

The PUBLIC_URL is the pathname of homepage

Reproducible demo

no demo

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:16
  • Comments:21

github_iconTop GitHub Comments

4reactions
Iamsotocommented, Feb 18, 2021

hi. Has there been any progress on this? I would also like a solution 😃

3reactions
nathan-alden-srcommented, Aug 1, 2022

Still happening as of today. The homepage property in package.json appears to be completely ignored by yarn build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't build create-react-app project with custom ...
The PUBLIC_URL is not something you set to a value of your choosing, ... validate if `homepage` is a URL or path like...
Read more >
7 - How do I get the public url of a file from the uri or filename
I am able to get the the uri of the file and or the filename. What drupal function can I use to get...
Read more >
The Public Folder (and favicons!!) in create-react-app
Perhaps the most important thing to know is that Webpack does not read the public folder; it will only read the files inside...
Read more >
A guide to Firebase Storage download URLs and tokens
But the method will return the same download URL for every invocation because there's only one (long-lived) token stored per file.
Read more >
Static Asset Handling
Importing a static asset will return the resolved public URL when it is served: ... Common image, media, and font filetypes are detected...
Read more >

github_iconTop Related Medium Post

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