0

I have a static React application that I want to host. I have a domain available too, say http://somedomainnamehere.com/. I'm new to React and web hosting. I looked up some tutorials and tried adding homepage attribute to package.json but that doesn't work.

package.json

{
  "name": "my-portfolio",
  "version": "0.1.0",
  "homepage": "http://somedomainnamehere.com/",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

After running the npm run build command, the message displayed is The project was built assuming it is hosted at /.

enter image description here

Can anyone help me understand what am I missing here? And if there's any other way to host my application?

1 Answers1

0

in your package.json file, change

"homepage": "http://somedomainnamehere.com/"

to

"homepage": "."

Then you can run npm run build once more. Please refer to this question.

After that, you can put content of build folder in virtually any host.

  • If you have a shared hosting account, you can put it directly to public_html folder.
  • If you have Heroku, you can follow tutorials to deploy static page like this tutorial.
  • Github Pages is also nice and free place to host your new project.

Hope this helps.

yogski
  • 181
  • 1
  • 10