ssg doesn't work for new data
When a user creates a new post, it doesn't generate a new site. I thought I could achieve that through
revalidate
but it doesn't seem to work. This is the code of post/[id].tsx:
It works in dev mode (due to dev mode), but it doesn't work in production (vercel)49 Replies
the not generated sites just 404
I doubt the revalidation works properly locally but it’s set to 1 second lol
I assume I should make that a bit bigger?
If it updates every second that’s fine 😂
well idk if it's the revalidate, but it does work locally, just takes a long time to load for some reason
Revalidation isn’t enabled for development
ohhhh
It’s just a normal request every time
u think changing revalidate will fix the problem? I might not understand correctly
It’s just x seconds
revalidate generally makes all the sites that have not been generated so far, generate, right? At least that's how I thought of it
You’re just passing x seconds
It will only re run the code if there has been more than x seconds since last “run”
Else it will just return a cached response
yeah okay
There’s also on demand revalidation
Haven’t tried it myself though
yeah I read about that, but I really wonder why the current code won't generate the new site
Errors?
And how do you know it isn t
after all, if validate is 1, it should try every second I guess
well I get a 404 when I try to connect
and when I re-deploy it works
Server error?
I can check vercels functions, but I don't think there is anything in there
It doesn’t just 404 😂
If it did without erroring I would be scared
maybe its not an error directly, but the code itself is just wrong
one sec
Your paths are wrong
You just passed []
Oh nvm phone view cursed
Debug time
I get this, but this is just because I check for auth each time a user conects
so no, vercel doesn't really give me any errors, so I think the code is just wrong
What if you build and run locally
one sec
same thing
so its not vercel, its the code
No errors either?
console is clear
Put on GitHub I clone when I get home
ke
GitHub
GitHub - vothvovo/nextjsdebug: oof
oof. Contribute to vothvovo/nextjsdebug development by creating an account on GitHub.
done
I put everything I know inside the readme.md
@Johnson
Deployed it myself, nothing wrong.
https://nextjsdebug.vercel.app/post/cl9mucr7c0000ju09ja9mm51o
As you can see, I put revalidation on 1 minute, the ISO string which is a date only changes if a minute has passed.
No problems.
wut
Don't know what you did wrong lol
Forgot to add env variables on Vercel's config?
I just logged in
and created a new post
click on it
it will give you a 404
lol
your discord account fucked up
wut
Oh I get why lol
Lemme test something
Yh you can't do it this way
fyi the sites do generate if you re-deploy
getStaticPaths only runs at build time.
yeah
but I thought
So the routes don't exist
Which is the problem
through
revalidate
I can re-run that
damnIt does but not getStaticPaths
ohh so I only run getStaticProps on
revalidate
well how do I solve this problem thencsr / ssr
can I implement some kind of logic that makes sure to only run ssr when there is no site available(so basically I haven't re-deployed yet)?