1

I have a NextJS app on Firebase working basically the way I want up to a point.

I can access it using a URL like: https://myownthing.web.app

Here is what I want to do next, to create a new route that I will access with: https://myownthing.web.app/Special

The app file system is now structured like this:

-> myownthing
    -> next.config.js
    -> firebase.json
    -> .....
    -> app
        -> page.tsx
        -> layout.tsx
        -> .....
        -> Special
            -> page.tsx

I have already managed to do part of the work. I added a directory called Special under app and a page.tsx inside it, as can be seen in the file system above.

And after running the command:

% npm run dev

I can locally access both routes (as expected):

http://localhost:3000
http://localhost:3000/Special

Next to set things the way I wish on the server side I run in the terminal:

% npm run build

and:

% firebase deploy --only hosting

At this point, I can access (as expected): https://myownthing.web.app

But when trying: https://myownthing.web.app/Special

I get:

404 | This page could not be found.

What am I doing wrong or forgetting ?

Some relevant hints would be welcome.

Michel
  • 10,303
  • 17
  • 82
  • 179

1 Answers1

0

Is it possibilie that you are watching cache? Tried to, ...

  • stop server
  • delete .next folder
  • run npm run dev again?
sensorario
  • 20,262
  • 30
  • 97
  • 159
  • I tried deleting .next as you suggest. But it doesn't change anything; after running "npm run dev" I see no problem at all, I can access as before, http://localhost:3000 and http://localhost:3000/Special as expected. The problem comes after, I cannot access https://myownthing.web.app/Special as explained in my post. – Michel May 14 '23 at 01:30
  • Please, ... could you paste here the conent of Special/page.tsx? – sensorario May 28 '23 at 09:24
  • See this link for a more detailed formulation of the same issue (with an accepted answer) https://stackoverflow.com/questions/76245907/extra-nextjs-routes-not-working-with-sample-provided. I am now facing a new issue: https://stackoverflow.com/questions/76346385/handling-dynamic-routes-with-next-js-on-firebase-server-side – Michel May 29 '23 at 03:31