Kit is prerendering an endpoint on build, I feel like I have tried everything #4562
StephenGunn
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
I will preface this with the project works 100% as intended in dev mode and almost perfectly in production/build. My project is using Netlify through the auto adapter and is using v1.0.0-next.308. It has a mixture of routes that I want to prerender and keep dynamic. I have been working on solving this one problem for far too many hours to admit. I am defeated.
I have updated the project to the new standards along the way, page endpoints, @layouts, get('cookie'), etc.
I have spent enough time trying to fix the problem to have narrowed it down. It seems to be a very specific behavior but also a bit tedious to recreate. So I'm not sure about posting this as a full on bug until I have tried everything. Still not convinced it's not my fault.
The Problem
I have an endpoint called /login (using /login/index.ts) that needs to be able to check for a refresh token and determine where to redirect if the token exists. All of this works great, I have no problem with my system. But when I link to /login anywhere on my index, and set my index to prerender using:
The build script will prerender the endpoint. This happens on Netlify and on my local machine when using npm run build
Since it prerenders the endpoint, it never checks for the refresh token when it is accessed in future. I have every instance of the link to /login set with rel="external" but it still seems to get prerendered. I didn't know endpoints could get prerendered yet.
If I remove the link to /login from the menu/homepage, it doesn't prerender the endpoint. So my quick fix is to create a buffer page to link to in my menu that has the link to /login on it.
Setting crawl to false in my prerender config also solves it but prevents dynamic pages from getting prerendered like /guests/[slug].svelte - I have tried every variation of the config I could think of but couldn't get the site to prerender everything I wanted when I had crawl set to false.
Am I missing something in my config? Are linked endpoints supposed to get prerendered? Am I taking crazy pills?
Any help or advice is appreciated, thank you :)
Beta Was this translation helpful? Give feedback.
All reactions