So I have a custom build script to add a 404 html file, as my React Router 404 doesn’t work with Vercel (it works locally). I tested it on my end and it creates the 404.html
just as required for a custom 404 in the docs. But it still shows the default 404 page. Here’s my script:
#!/bin/bash
bun run build
cd dist
echo "
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Error 404</title>
</head>
<body>
<style>
.notFoundContainer {
width:100%;
height:100%;
display:flex;
flex-direction: column;
align-items:center;
justify-content:center;
}
</style>
<div className="notFoundContainer">
<h1>404. Looks like this page is missing.</h1>
<p>This can happen for a number of reasons, including a typo in the URL, a broken/outdated link, or a typo on our end.</p>
</div>
</body>
</html>
" > 404.html