Ask Your Question
4

The React Vite app is properly published on GitHub pages, but navigation leads to a 404 error.

asked 2021-12-21 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-01 22:00:00 +0000

bukephalos gravatar image

This issue is likely caused by incorrect routing configuration within the React Vite app. Here are a few potential solutions to try:

  1. Update the basename property in the BrowserRouter component to match the name of your GitHub repository. For example, if your repository is named my-react-app, you would update your BrowserRouter component as follows:
import { BrowserRouter } from 'react-router-dom';

<BrowserRouter basename="/my-react-app">
  {/* your routes go here */}
</BrowserRouter>
  1. Ensure that all of your route paths are relative to the basename value. For example, if you have a route with a path of /about, you would update it to be my-react-app/about to match the basename value.

  2. If you are using a custom domain for your GitHub pages site, make sure that your CNAME file is set up correctly and that your DNS settings are pointing to the correct GitHub Pages IP address.

  3. Double check that your GitHub pages deployment has completed successfully and that all necessary files have been uploaded.

If none of these solutions work, you may need to dive deeper into your app's routing configuration to identify the root cause of the issue.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-21 11:00:00 +0000

Seen: 7 times

Last updated: Sep 01 '22