Skip to content

Commit

Permalink
Return a 400 BadRequest for HEAD and GET requests that include a body (
Browse files Browse the repository at this point in the history
…#2360)

This is necessary because the Remix handler throws, causing a 500 error
  • Loading branch information
blittle committed Jul 31, 2024
1 parent dfb9be7 commit 20a8e63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-dragons-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/remix-oxygen': patch
---

Return a 400 BadRequest for HEAD and GET requests that include a body
8 changes: 8 additions & 0 deletions packages/remix-oxygen/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ export function createRequestHandler<Context = unknown>({
const handleRequest = createRemixRequestHandler(build, mode);

return async (request: Request) => {
const method = request.method;

if ((method === 'GET' || method === 'HEAD') && request.body) {
return new Response(`${method} requests cannot have a body`, {
status: 400,
});
}

const context = getLoadContext
? ((await getLoadContext(request)) as AppLoadContext)
: undefined;
Expand Down

0 comments on commit 20a8e63

Please sign in to comment.