Skip to content
Open
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion packages/start-server-core/src/server-functions-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import { getServerFnById } from './getServerFnById'

let regex: RegExp | undefined = undefined

const methodNotAllowed = (expectedMethod: string, actualMethod: string) => {
throw new Response(`expected ${expectedMethod} method. Got ${actualMethod}`, {
status: 405,
headers: {
Allow: expectedMethod,
},
})
}

export const handleServerAction = async ({
request,
context,
Expand Down Expand Up @@ -119,7 +128,7 @@ export const handleServerAction = async ({
}

if (method.toLowerCase() !== 'post') {
throw new Error('expected POST method')
throw methodNotAllowed('POST', method)
}

let jsonPayload
Expand Down
Loading