Next.js Discord

Discord Forum

app router page not working

Answered
Sam Apostel posted this in #help-forum
Open in Discord
In my blog I have project pages.
app/p/[slug]/page.tsx
I fetch data from a database and render the article using markdown.
This works.


Now I want to add a page for a specific project that won't get it's data from the database.
app/p/polar-printer/page.tsx

This works in development but when I deploy on vercel the /p/polar-printer page uses the [slug] path.

Code: https://github.com/Sam-Apostel/blog
deployed page: https://sams.land/p/polar-printer
Answered by riský
ok that was worded badly, i try again:
* try to manually filter out this slug from your generateStaticParams
* add metadata to your p/polar-printer
* and a friend @\joulev also suggested if not above: try to add dynamicParams = false do dynamic route https://canary.discord.com/channels/752553802359505017/766433464055496744/1255496931086569473
View full answer

27 Replies

if you have /p/polar-printer/page/tsx it should take preference over dynamic slug
in your code, are you 100% sure that the markdown is working though
in dev it works
also do you have example for working page/post in dynamic route
hmm yeah it is using that... i really am confused
and as you said dev is fine
you could always do an if check and return that page, but thats kinda sad (i am not able to know the issue, as its worked well for me on vercel)
jup
wait can you remove this slug from your generatestaticparams
i feel like it could be overriding and taking priority
if not that, i was going to wonder if it was because the [slug] had generatemetadata and the page didnt and it would be funny if that was the bug
Ahah! that's a great suggestion!
ok that was worded badly, i try again:
* try to manually filter out this slug from your generateStaticParams
* add metadata to your p/polar-printer
* and a friend @\joulev also suggested if not above: try to add dynamicParams = false do dynamic route https://canary.discord.com/channels/752553802359505017/766433464055496744/1255496931086569473
Answer
change is building right now..
And it works!
YOOOOO
Thank you so much. A second pair of eyes was definitely needed on this one.
@Sam Apostel Thank you so much. A second pair of eyes was definitely needed on this one.
no problem, its fun when vercel does things diferently then normal
For anyone else checking out this issue:

I did this for now.
const dedicatedPages = ['polar-printer'];
export async function generateStaticParams() {
  const projects = await xata.db.project.filter({ published: true }).select(['slug']).getAll();

  return projects
    .filter((project) => !dedicatedPages.includes(project.slug))
    .map((project) => ({
      slug: project.slug,
    }));
}
Will make it a toggle in my db later.
@Sam Apostel do you have a paid plan with vercel? if yes, i would suggest you flagging this to them by making a support case, this is a vercel bug
sounds good make sure to update your metadata for static in that individual page.tsx as now i feel like it wont get from db
@joulev <@293358654244257793> do you have a paid plan with vercel? if yes, i would suggest you flagging this to them by making a support case, this is a vercel bug
no paid account, any other place to report this? I don't feel like this is a bug but an error in my code. I specifically tell the page to generate with that URL
its more the fact it works on normal local, and diferent on vercel... so vercel has a bug then
@riský sounds good make sure to update your metadata for static in that individual page.tsx as now i feel like it wont get from db
it works on dev because dev doesn't do static page generation. Maybe a warning during the build should fix it. more of a nextjs bug than vercel
@Sam Apostel no paid account, any other place to report this? I don't feel like this is a bug but an error in my code. I specifically tell the page to generate with that URL
dev mode works differently from a prod mode is a conclusive evidence to say it is either a nextjs bug or a vercel bug.

if local prod mode (npm run start) also works well, then it is 100% a vercel bug.

to report a nextjs bug: https://github.com/vercel/next.js/issues though it's unlikely to get any attention.

to report a vercel bug: for a typical user the only way to do that is by creating support cases (a paid plan is required) or by the feedback button at the top right (all plans, but unlikely to get any attention).