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.

Kim Vu
  • 584
  • 9
  • 25

1 Answers1

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,
};
Kim Vu
  • 584
  • 9
  • 25
  • 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 Jan 04 '23 at 20:06