firebaseroutesnext.jshostingfirebase-hosting

Nextjs dynamic routing not working in firebase hosting


I have a dynamic router job/[jobId] but it doesn't work after hosting. I don't know how to write the rewrites in firebase.json for this as well. Here's my rewrites.

Currently firebase throws 404 if I access a page such as job/2 page

Output structure

├── job
│   └── [jobId]
│       └── index.html

pages structure

.
├── _app.js
├── _document.js
├── careers
│   └── index.js
├── index.js
├── job
│   └── [jobId].js
└── privacy.js

Rewrites

"rewrites": [
      {
        "source": "job/**",
        "destination": "job/[jobId]/index.html"
      }

Solution

  • "rewrites": [
          {
            "source": "/job/**",
            "destination": "/job/[jobId]/index.html"
          }
    

    Starting / was missing