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

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

Open
elvisLAI opened this issue Apr 9, 2020 · 21 comments · May be fixed by #9771
Open

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

elvisLAI opened this issue Apr 9, 2020 · 21 comments · May be fixed by #9771

Comments

@elvisLAI
Copy link

elvisLAI commented Apr 9, 2020

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

@Gcolon021
Copy link

Gcolon021 commented Apr 21, 2020

Does anyone have a fix for this other than changing version to react-scripts@3.3.0? I changed the version and it created an issue as follows: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Found the fix. Changed react-dev-utils to 10.1.0

@stale
Copy link

stale bot commented May 22, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label May 22, 2020
@anthem-bmk
Copy link

Bumping this to prevent the stalebot from closing it. This is still a relevant issue. #7259 accidentally introduced a breaking change into v3.4.0

@stale stale bot removed the stale label May 25, 2020
@stale
Copy link

stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jun 26, 2020
@redbmk
Copy link

redbmk commented Jun 26, 2020 via email

@stale stale bot removed the stale label Jun 26, 2020
@jeffersoneagley
Copy link

Just ran into this too.

@tsharp
Copy link

tsharp commented Jul 24, 2020

Ran into this as well - trying to host multiple react sites under a single domain \(〇_o)/

@fonziemedia
Copy link

Having the same issue here.. any update?

@fonziemedia
Copy link

Does anyone have a fix for this other than changing version to react-scripts@3.3.0? I changed the version and it created an issue as follows: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Found the fix. Changed react-dev-utils to 10.1.0

Appreciate you sharing this but it did not work for me..

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Sep 20, 2020
@redbmk
Copy link

redbmk commented Sep 20, 2020

Bump - this is still an issue. I'll try to find time to look into this soon.

@stale stale bot removed the stale label Sep 20, 2020
redbmk added a commit to redbmk/create-react-app that referenced this issue Oct 9, 2020
@redbmk redbmk linked a pull request Oct 9, 2020 that will close this issue
@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 25, 2020
@redbmk
Copy link

redbmk commented Dec 26, 2020

I have an open PR for this: #9771

is anyone able to review it? @elvisLAI ?

@stale stale bot removed the stale label Dec 26, 2020
@i-am-b-soto
Copy link

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

@dreamyguy
Copy link

I fixed a similar error by setting the homepage on package.json to an empty string:

   "homepage": "",

Before I did that I was getting the app initialised locally with unwanted URL, something like:

  Local:            http://localhost:3000/this-and-that/and-some-more
  On Your Network:  http://192.168.1.47:3000/this-and-that/and-some-more

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jun 26, 2021
@redbmk
Copy link

redbmk commented Jun 28, 2021

I'll try to remember to update my PR since I'm sure there are conflicts by now, but I don't think anyone ever reviewed it. Is there someone that would be willing to give some feedback on #9771?

@stale stale bot removed the stale label Jun 28, 2021
prince-thind added a commit to prince-thind/memory-cards that referenced this issue Aug 8, 2021
There seems to be bug with CRA right now, as a temporaray solution, the homepage has been chnaged to .
details here: facebook/create-react-app#8813
@sgaweda
Copy link

sgaweda commented Aug 30, 2021

This is an insidious bug. I was able to resolve this for myself using the following steps:

  1. Add a .env file in the same folder as package.json
  2. Populate it with PUBLIC_URL=https://example.com. If you're trying to set this up with github pages then you will likely need PUBLIC_URL=https://user-name.github.io/repo-name.
  3. Run npm run build.
    After these steps I was finally able to see my react site render correctly. In my use case I was trying to host a site using github pages and a custom domain name. This bug ensured that my react app continued to look for my site's contents under the custom domain instead of the github domain listed under homepage in package.json.

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 9, 2022
@pal85adam
Copy link

Having the same issue!

@stale stale bot removed the stale label Jan 19, 2022
sh4nnongoh added a commit to sh4nnongoh/flight-search that referenced this issue Mar 21, 2022
@nathan-alden-sr
Copy link

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

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

Successfully merging a pull request may close this issue.