Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root path broken when deployed #506

Open
anselanza opened this issue Mar 13, 2024 · 0 comments
Open

Root path broken when deployed #506

anselanza opened this issue Mar 13, 2024 · 0 comments

Comments

@anselanza
Copy link

anselanza commented Mar 13, 2024

I used this template/starter pretty much "as is" and tried to deploy the site on GitHub Pages (with a Tina Cloud backend). While everything worked normally in development, the root path was always broken when deployed.

Specifically, I would get the "404 - Page Not Found" page when first visiting the root of the site /, instead of the home page.

Clicking on any link from this point would work absolutely fine, including "Home". The browser would even display the root URL / (not /home), but you could reload the page and you would be back at the 404 page again.

A fellow web dev who knows Next.JS better than me advised that I add an index.tsx file in ./pages (for some reason this is missing in the template?), and this solved my problem immediately. The contents of the file were quite simple:

import Filename, { getStaticProps as FilenameStaticProps } from "./[filename]";

const Index = Filename;

export const getStaticProps = async ({ params }) => {
  return FilenameStaticProps({ params: { filename: "home" } });
};

export default Index;

No other changes were needed in configuration and code.

I'm curious whether anyone else has encountered a similar problem. Is this specific to GitHub Pages deployments somehow? If so, how come nobody else noticed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant