Skip to content

fix(vercel): add check for index route rule - #1290

Merged
pi0 merged 2 commits into
nitrojs:mainfrom
MikeBellika:main
Jun 20, 2023
Merged

pi0 merged 2 commits into
nitrojs:mainfrom
MikeBellika:main

Conversation

@MikeBellika

@MikeBellika MikeBellika commented Jun 7, 2023 •

Copy link
Copy Markdown
Contributor

🔗 Linked issue

#1287

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

When using ISR on vercel on the index route, it always returned 404.
Before the vercel config.json would look something like this when ISR was enabled on /:

{
  "version": 3,
  "overrides": {},
  "routes": [
    {
      "handle": "filesystem"
    },
    {
      "src": "/",
      "dest": "/__nitro-index?url=$url"
    },
    {
      "src": "(?<url>/)",
      "dest": "/__nitro-index"
    },
    {
      "src": "/(.*)",
      "dest": "/__nitro"
    }
  ]
}

After this change it will look something like this:

{
  "version": 3,
  "overrides": {},
  "routes": [
    {
      "handle": "filesystem"
    },
    {
      "src": "(?<url>/)",
      "dest": "/__nitro-index?url=$url"
    },
    {
      "src": "/(.*)",
      "dest": "/__nitro"
    }
  ]
}

This seems to work on vercel and the tests still pass.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov

codecov Bot commented Jun 7, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #1290 (6f2b30a) into main (0ffab31) will increase coverage by 0.68%.
The diff coverage is 50.00%.

❗ Current head 6f2b30a differs from pull request most recent head 7dc5ac3. Consider uploading reports for the commit 7dc5ac3 to get more accurate results

@@            Coverage Diff             @@
##             main    #1290      +/-   ##
==========================================
+ Coverage   76.21%   76.89%   +0.68%     
==========================================
  Files          68       68              
  Lines        6949     6829     -120     
  Branches      686      694       +8     
==========================================
- Hits         5296     5251      -45     
+ Misses       1652     1577      -75     
  Partials        1        1              
Impacted Files Coverage Δ
src/presets/vercel.ts 94.03% <50.00%> (ø)

... and 11 files with indirect coverage changes

@pi0
pi0 requested a review from danielroe June 7, 2023 15:03
@pi0 pi0 changed the title fix: add check for index on vercel fix(vercel): add check for index route rule Jun 20, 2023
@pi0
pi0 merged commit 461b8a4 into nitrojs:main Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants