v1.0.0-alpha.0
Pre-releaseWhat's Changed
- fix: Unify request handling for pages and RSC actions by @justinvdm in #715
Full Changelog: v0.3.8...v1.0.0-alpha.0
BREAKING CHANGE
React Server Component (RSC) actions now run through the global middleware pipeline. Previously, action requests bypassed all middleware.
This change allows logic for authentication, session handling, and security headers to apply consistently to all incoming requests. However, if you have existing middleware, it will now execute for RSC actions, which may introduce unintended side effects.
Migration Guide
You must review your existing global middleware to ensure it is compatible with RSC action requests. A new isAction boolean flag is now available on the requestInfo object passed to middleware, making it easy to conditionally apply logic.
If you have middleware that should only run for page requests, you need to add a condition to bypass its logic for action requests.
Example:
Let's say you have a middleware that logs all incoming page requests. You would modify it to exclude actions like so:
// src/worker.tsx
const loggingMiddleware = ({ isAction, request }) => {
// Check if the request is for an RSC action.
if (isAction) {
// It's an action, so we skip the logging logic.
return;
}
// Otherwise, it's a page request, so we log it.
const url = new URL(request.url);
console.log('Page requested:', url.pathname);
};
export default defineApp([
loggingMiddleware,
// ... your other middleware and routes
]);