Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Fixes

* Specify the content type when calling back to Astro with JSON to render an area. This is required starting in Astro 4.9.0 and up, otherwise the request is blocked by CSRF protection.

## 4.23.0 (2025-10-30)

### Adds
Expand Down
4 changes: 3 additions & 1 deletion modules/@apostrophecms/area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ module.exports = {
const response = await fetch(`${self.apos.baseUrl}/api/apos-external-front/render-area`, {
method: 'POST',
headers: {
'apos-external-front-key': self.apos.externalFrontKey
'apos-external-front-key': self.apos.externalFrontKey,
// Without this Astro enforces CSRF protection starting in version 4.9.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course it is always appropriate to specify a content type here so I'm not really blaming Astro but they started enforcing it recently

'content-type': 'application-json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this instead or I'm missing something?

Suggested change
'content-type': 'application-json'
'content-type': 'application/json'

},
body: JSON.stringify({
area
Expand Down