I have a Parcel/React App that I am attempting to launch to production. After testing, I see that my navigation no longer works on the server (404s).
I'm using React Router like so:
<Suspense fallback={<div>Loading...</div>}>
<Router primary={false}>
<Home path="/" />
<About path="/about" />
<Portfolio path="work" />
<Contact path="/contact" />
</Router>
</Suspense>
I added homepage to my package.json as suggested in another thread, but still no luck.
"homepage": "."
I don't have any experience with IIS manager or anything like that so I am hesitant to make any server changes there, especially since I have other websites on the same server.
Is there anything that can be done in the code/build to make this work on the server, or will it require IIS changes?
Here is my package.json:
{
"name": "ericbelldesigns",
"version": "1.0.0",
"description": "Eric Bell Designs 2020",
"main": "src/App.js",
"dependencies": {
"@frontendmasters/pet": "^1.0.3",
"@reach/router": "^1.3.1",
"anime": "^0.1.2",
"axios": "^0.19.2",
"bezier-easing": "^2.1.0",
"charming": "^3.0.1",
"gsap": "^2.1.3",
"gsap-react-plugin": "^1.0.2",
"imagesloaded": "^4.1.4",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"three": "^0.106.2",
"three-obj-loader": "^1.1.3",
"three-orbit-controls": "^82.1.0"
},
"browserslist": [
"last 2 Chrome versions",
"last 2 ChromeAndroid versions",
"last 2 Firefox versions",
"last 2 FirefoxAndroid versions",
"last 2 Safari versions",
"last 2 iOS versions",
"last 2 Edge versions",
"last 2 Opera versions",
"last 2 OperaMobile versions"
],
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"animejs": "^3.1.0",
"babel-eslint": "^10.0.3",
"cross-env": "^5.2.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.0",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^1.6.1",
"parcel-bundler": "^1.12.4",
"parcel-plugin-html-externals": "^0.1.2",
"postcss-modules": "^1.5.0",
"prettier": "^1.19.1",
"sass": "^1.26.0",
"threejs-controls": "^1.0.6"
},
"scripts": {
"dev": "parcel src/index.html",
"dev:mock": "cross-env PET_MOCK=mock npm run dev",
"format": "prettier --write \"src/**/*.{js,jsx}\"",
"lint": "eslint \"src/**/*.{js,jsx}\" --quiet",
"test": "echo \"Error: no test specified\" && exit 1",
"production": "parcel build src/index.html"
},
"externals": {
"/images/**/*": false
},
"author": "Eric Bell <eric@ericbelldesigns.com>",
"license": "Apache-2.0",
"keywords": []
}
If you imported BrowserRouter
change it to HashRouter
instead and see if that helps.