Talat El Beick
Talat El Beick

Reputation: 531

React images not loading locally after gh-pages installation

I'm trying to deploy a react app on gh-pages and I have done it successfully, but after deploying I did run again the app on local server to add some new feature, I seen that is dose not loading images which was loaded before.

{
  "name": "react-tesla-clone",
  "homepage": "https://elbeicktalat.github.io/react-tesla-clone",
  "version": "0.1.0",
  "private": true,
  "dependencies": {...},
  "scripts": {
    "predeploy": "yarn run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "gh-pages": "^3.2.3"
  }
}

Before gh-pages setting up

Before gh-pages setting up

After gh-pages setting up

After gh-pages setting up

So what is the solution?

Upvotes: 2

Views: 144

Answers (1)

Talat El Beick
Talat El Beick

Reputation: 531

All that caused by package.json homepage property, infact if you remove it you'll solve this isuse, but removing it every time you want run the project localy is not the best idea.

so what we can do instead? very simple just create .env file in the project root folder and add the following in it:

PUBLIC_URL="."

Upvotes: 3

Related Questions