Search code examples
reactjsgithub-pagesweb-hostingnamecheap

github pages + namecheap domain = response status 404


I'm trying to add a domain name to my react app but I get a 404 response when I added it. It works fine in github pages hosting but when I add the domain I get the error. not sure if I'm missing something in my package.json file? please help, I've been stuck for quite some time now.

this is my package.json

{
  "name": "casahogar",
  "homepage": "https://castillojuan1000.github.com/casaHogar",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "@material-ui/icons": "^4.9.1",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "axios": "^0.20.0",
    "cors": "^2.8.5",
    "emailjs-com": "^2.6.3",
    "express": "^4.17.1",
    "feather-icons": "^4.28.0",
    "framer-motion": "^1.11.1",
    "gh-pages": "^3.1.0",
    "react": "^16.13.1",
    "react-axios": "^2.0.3",
    "react-dom": "^16.13.1",
    "react-modal": "^3.11.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^3.4.3",
    "react-scroll": "^1.8.1",
    "react-slick": "^0.26.1",
    "react-stripe-checkout": "^2.6.3",
    "react-toastify": "^6.0.9",
    "slick-carousel": "^1.8.1",
    "smoothscroll-polyfill": "^0.4.4",
    "stripe": "^8.108.0",
    "styled-components": "^5.1.1",
    "tailwindcss": "^1.4.6",
    "twin.macro": "^1.4.1",
    "use-in-view": "^1.0.15",
    "uuid": "^8.3.1",
    "uuidv4": "^6.2.4"
  },
  "proxy": "http://localhost:4242",
  "scripts": {
    "server": "nodemon src/Server.js",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
  "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"
    ]
  },
  "devDependencies": {
    "nodemon": "^2.0.4"
  }
}

this is my setup in namecheap: enter image description here


Solution

  • Your website is trying to fetch the static assets (JS and CSS) from the wrong URL. It's requesting them at https://www.casahogarscj.com/casaHogar/static/... while Github serves them at https://www.casahogarscj.com/static/... (without casaHogar).

    To fix this, you need to change the homepage value to https://www.casahogarscj.com/ in your package.json and rebuild your website.