Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opting out from Vercel ISR not working for paths with rest parameters #372

Open
1 task done
hrabiel opened this issue Sep 2, 2024 · 1 comment
Open
1 task done

Comments

@hrabiel
Copy link
Contributor

hrabiel commented Sep 2, 2024

Astro Info

Astro                    v4.15.2
Node                     v20.16.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/vercel/serverless
Integrations             none

Describe the Bug

According to the documentation, Vercel adapter allows to exclude specific paths from caching with ISR. This works correctly for static and dynamic routes with a parameter, but doesn't work with the routes that include rest parameters.

Example:

import vercel from '@astrojs/vercel/serverless';
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
  output: 'server',
  adapter: vercel({
    isr: {
      exclude: [
        "/one", // works
        "/excluded/[slug]", // works
        "/excluded/[...rest]", // doesn't work, it's not excluded
      ]
    }
  })
});

What's the expected result?

All routes added to the isr.excluded Vercel adapter config should be excluded from caching, including those with rest parameters.

Link to Minimal Reproducible Example

https://github.com/hrabiel/astro-vercel-adapter-demo

Participation

  • I am willing to submit a pull request for this issue.
@hrabiel
Copy link
Contributor Author

hrabiel commented Sep 2, 2024

The issue seems to be caused by the incorrect generation of a route with rest parameters. It puts an extra slash in the src regex.
Expected: "^/excluded(?:\\/(.*?))?$"
Actual: "^/excluded/(?:\\/(.*?))?$"

Opened a PR with the fix for this: #373

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

No branches or pull requests

1 participant