1

I'm using SSG with nextjs and run "next export" to create static files in /out folder. But when the app is deployed i get a lot of HTTP GET-request from router.js enter image description here

All the files that are trying to get fetched are some kind of a json file of my pages. But why are they json? and why does this only happen in deployed? and not in dev? I haven't specified any fetches for json files. But could be related to how i use next/link

I have some code which shows how i have used the next/link

 <Link
    href={'/' + nav.page.slug.current}
    as={isDev ? undefined : `/${nav.page.slug.current}.html`}
 >
    <a style={{ textDecoration: 'none' }}>
      <StyledLink active={activePage === nav.page.slug.current}>
         {nav.page.title}
      </StyledLink>
    </a>
 </Link>

StyledLink is just a styled components for a span.

0

1 Answer 1

0

I had to add this to my next.config.js and remove all the .html-logic i had in my Link (basically removed the "as"-prop)

module.exports = {
  trailingSlash: true,
};
1
  • this helped point me in the right direction. definitly works when i add a slash to the end, although trailingSlash: true is already in my exports
    – bonez
    Commented Jan 4, 2023 at 20:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.