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

[ci] release (beta) #12405

Merged
merged 1 commit into from
Nov 13, 2024
Merged

[ci] release (beta) #12405

merged 1 commit into from
Nov 13, 2024

Conversation

astrobot-houston
Copy link
Contributor

@astrobot-houston astrobot-houston commented Nov 8, 2024

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to next, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

next is currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, run changeset pre exit on next.

⚠️⚠️⚠️⚠️⚠️⚠️

Releases

[email protected]

Minor Changes

  • #12373 d10f918 Thanks @bholmesdev! - Changes the default behavior for Astro Action form requests to a standard POST submission.

    In Astro 4.x, actions called from an HTML form would trigger a redirect with the result forwarded using cookies. This caused issues for large form errors and return values that exceeded the 4 KB limit of cookie-based storage.

    Astro 5.0 now renders the result of an action as a POST result without any forwarding. This will introduce a "confirm form resubmission?" dialog when a user attempts to refresh the page, though it no longer imposes a 4 KB limit on action return value.

    Customize form submission behavior

    If you prefer to address the "confirm form resubmission?" dialog on refresh, or to preserve action results across sessions, you can now customize action result handling from middleware.

    We recommend using a session storage provider as described in our Netlify Blob example. However, if you prefer the cookie forwarding behavior from 4.X and accept the 4 KB size limit, you can implement the pattern as shown in this sample snippet:

    // src/middleware.ts
    import { defineMiddleware } from 'astro:middleware';
    import { getActionContext } from 'astro:actions';
    
    export const onRequest = defineMiddleware(async (context, next) => {
      // Skip requests for prerendered pages
      if (context.isPrerendered) return next();
    
      const { action, setActionResult, serializeActionResult } = getActionContext(context);
    
      // If an action result was forwarded as a cookie, set the result
      // to be accessible from `Astro.getActionResult()`
      const payload = context.cookies.get('ACTION_PAYLOAD');
      if (payload) {
        const { actionName, actionResult } = payload.json();
        setActionResult(actionName, actionResult);
        context.cookies.delete('ACTION_PAYLOAD');
        return next();
      }
    
      // If an action was called from an HTML form action,
      // call the action handler and redirect with the result as a cookie.
      if (action?.calledFrom === 'form') {
        const actionResult = await action.handler();
    
        context.cookies.set('ACTION_PAYLOAD', {
          actionName: action.name,
          actionResult: serializeActionResult(actionResult),
        });
    
        if (actionResult.error) {
          // Redirect back to the previous page on error
          const referer = context.request.headers.get('Referer');
          if (!referer) {
            throw new Error('Internal: Referer unexpectedly missing from Action POST request.');
          }
          return context.redirect(referer);
        }
        // Redirect to the destination page on success
        return context.redirect(context.originPathname);
      }
    
      return next();
    });

Patch Changes

  • #12339 bdb75a8 Thanks @ematipico! - Adds an error when Astro.rewrite() is used to rewrite an on-demand route with a static route when using the "server" output.

    This is a forbidden rewrite because Astro can't retrieve the emitted static route at runtime. This route is served by the hosting platform, and not Astro itself.

@github-actions github-actions bot added pkg: example Related to an example package (scope) pkg: astro Related to the core `astro` package (scope) labels Nov 8, 2024
@ematipico ematipico merged commit b745e38 into next Nov 13, 2024
@ematipico ematipico deleted the changeset-release/next branch November 13, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants