Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/en/guides/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ Actions are accessible as public endpoints based on the name of the action. For

To authorize action requests, add an authentication check to your action handler. You may want to use [an authentication library](/en/guides/authentication/) to handle session management and user information.

Actions expose the full `APIContext` object to access properties passed from middleware using `context.locals`. When a user is not authorized, you can raise an `ActionError` with the `UNAUTHORIZED` code:
Actions expose the `ActionAPIContext` object, a subset of `APIContext`, to access properties passed from middleware using `context.locals`. When a user is not authorized, you can raise an `ActionError` with the `UNAUTHORIZED` code:

```ts title="src/actions/index.ts" {6-8}
import { defineAction, ActionError } from 'astro:actions';
Expand Down
32 changes: 32 additions & 0 deletions src/content/docs/en/guides/upgrade-to/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,38 @@ prefetch('/about');

<ReadMore>Learn more about [prefetching](/en/guides/prefetch/).</ReadMore>

### Removed: `rewrite()` from Actions context

<SourcePR number="14477" title="feat!: remove rewrite from action context"/>

In Astro 5.5.6, the `ActionAPIContext.rewrite` method was deprecated because custom endpoints should be used instead of rewrites.

Astro 6.0 removes the `rewrite()` method from `ActionAPIContext` entirely and it may no longer be used.

#### What should I do?

Review your Actions handlers and remove any call to `rewrite()`:


```ts title="src/actions/index.ts" del={10}
import { defineAction } from 'astro:actions';
import { z } from 'astro:schema';

export const server = {
getGreeting: defineAction({
input: z.object({
// ...
}),
handler: async (input, context) => {
context.rewrite('/')
// ...
}
})
}
```

<ReadMore>Learn more about [rewrites](/en/guides/routing/#rewrites).</ReadMore>

### Experimental Flags

The following experimental flags have been removed in Astro v6.0 and these features are available for use:
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/modules/astro-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const server = {

`defineAction()` requires a `handler()` function containing the server logic to run when the action is called. Data returned from the handler is automatically serialized and sent to the caller.

The `handler()` is called with user input as its first argument. If an [`input`](#input-validator) validator is set, the user input will be validated before being passed to the handler. The second argument is a `context` object containing most of Astro’s [standard endpoint context](/en/reference/api-reference/), excluding `getActionResult()`, `callAction()`, and `redirect()`.
The `handler()` is called with user input as its first argument. If an [`input`](#input-validator) validator is set, the user input will be validated before being passed to the handler. The second argument is a `context` object containing most of Astro’s [standard endpoint context](/en/reference/api-reference/), excluding `getActionResult()`, `callAction()`, `redirect()` and `rewrite()`.

Return values are parsed using the [devalue library](https://github.com/Rich-Harris/devalue). This supports JSON values and instances of `Date()`, `Map()`, `Set()`, and `URL()`.

Expand Down