I am trying to build my app via npm run build
.
In my index.html
which is found in the root I have the following content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="/env-config.js"></script>
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using Vite"
/>
<link rel="apple-touch-icon" href="/favicon.ico" />
<link rel="manifest" href="/manifest.json" />
<title>Some Tool</title>
<script type="module" src="/src/main.jsx"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
After running the npm run build
command, all paths become relative. This of course is not what I need. When I refresh my react app from a sub-route, let’s say /users these files defined in the index.html
can not be found.
Working: localhost:3000/manifest.json
NOT: localhost:3000/users/manifest.json
I read that the Vite by default changes all paths to relative. I don’t want that.
I did read, that by adding in the vite.config.js
the base: '/'
the problem could be solved, but unfortunately it didnt.