Skip to content

Conversation

@psd-coder
Copy link
Collaborator

@psd-coder psd-coder commented Aug 27, 2025

This pull request introduces two major integrations to the Astro project:

  • Custom Vercel middleware generator. It replaces our custom scripts pipeline and tightly integrated with Astro's lifecycle.
  • Replaces matcher generation script with one more Astro integration.

How it works

  • New build method is provided as custom Astro middleware integration. During build time it compiles Astro middleware (not the custom one, as we had before) into Vercel output format, but since we could have any middleware (not only i18n) then matcher check was moved into i18n middleware itself.
  • By default, middleware processes any request to the application, but we limit it to ignore static asset files.
  • generate-middleware-matcher.js was transformed into one more additional Astro integration. It allows running it in Astro lifecycle: when you update any route-dependant files it automatically regenerates output file. Astro integration fails if you use dynamic imports inside it (something related to Vite), so everything we imported before just in the place now we have to pass as integration options.
  • All middlewares were converted into Astro middleware format.
  • Since we build website into static there is extra check in the i18n middleware whether it is called during build. Headers and cookies are empty when ctx.isPrerendered === true. It works well when the app is deployed.

@vercel
Copy link

vercel bot commented Aug 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
aptos-docs Ready Ready Preview Comment Sep 9, 2025 5:52pm

@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from dd5c1d0 to 860abc6 Compare August 27, 2025 20:48
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from 860abc6 to 39ef699 Compare August 27, 2025 21:00
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from 52dd955 to ebcd2e5 Compare August 27, 2025 21:21
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from ebcd2e5 to ecbc834 Compare August 28, 2025 16:56
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from 772ff00 to 8a71c21 Compare August 28, 2025 17:43
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from 8a71c21 to 484a8e3 Compare August 28, 2025 17:55
@psd-coder psd-coder force-pushed the integrate-custom-vercel-middleware-integration branch from 484a8e3 to 13af42f Compare September 3, 2025 13:56
…he old scripts. Convert matchers generation script into another Astro integration, to have better DX (it regenerates file automatically according to the Astro pipeline and doesn't require any extra vague scripts setup).
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.

2 participants