your site's address is /repo-name), then you need to set pathSegmentsToKeep to 1 in the 404.html file in order to keep /repo-name in the path after the redirect.
For example, example.tld/one/two?a=b&c=d#qwe, becomes example.tld/?/one/two&a=b~and~c=d#qwe. The custom 404.html page contains a script that takes the current url and converts the path and query string into just a query string, and then redirects the browser to the new url with only a query string and hash fragment. example.tld/foo, it returns a custom 404.html page. When the GitHub Pages server gets a request for a path defined with frontend routes, e.g. When there is a fresh page load for a url like example.tld/foo, where /foo is a frontend route, the GitHub Pages server returns 404 because it knows nothing of /foo.
GitHub Pages doesn't natively support single page apps. You can easily deploy a React single page app with React Router, like the one in the demo app, or a single page app built with any frontend library or framework. This is a lightweight solution for deploying single page apps with GitHub Pages.