Missing Http method returns 200 status code on api route

I am trying to generate API routes. In the docs I read that 405 is returned for non existing routes but when I create one let's say /api/logout and only define a DELETE method , if I call put on it it returns code 200 and html. Is this correct or have I missed something? Do I have to define all the methods I do not use and return 405 on them myself? /api/logout.ts code below
import { APIEvent } from 'solid-start/api'

export async function DELETE({ request, params }: APIEvent) {
//...api stuff here

return new Response('')
}
import { APIEvent } from 'solid-start/api'

export async function DELETE({ request, params }: APIEvent) {
//...api stuff here

return new Response('')
}
No description
12 Replies
vibeman1987
vibeman198710mo ago
we're gonna need more of the code dawg
Silverdagger
Silverdagger10mo ago
I believe it is pretty straightforward I have only defined DELETE on this route -> when PUT is called it returns html and what i expected to happen is return 405.
No description
vibeman1987
vibeman198710mo ago
ohhh nevermind I gotchu yeah lemme check if you want something custom:
export const POST = ()=>{return new Response("Error: POST not supported", {status : 405})}
export const POST = ()=>{return new Response("Error: POST not supported", {status : 405})}
I haven't found anything in the docs that gives an alternative @silverdagger
Silverdagger
Silverdagger10mo ago
yeah this is what I do atm -> create catch all routes and return 405 on all of them myself -> Just thought that maybe I missed something to "enable" this feature to do it for any undefined routes
vibeman1987
vibeman198710mo ago
wait @silverdagger in what folder are your endpoints?
If a handler is not defined for a given HTTP method, SolidStart will return a 405 Method Not Allowed response.
If a handler is not defined for a given HTTP method, SolidStart will return a 405 Method Not Allowed response.
Silverdagger
Silverdagger10mo ago
routes/api/endpoint.ts
vibeman1987
vibeman198710mo ago
Have you wrapped anything in your Index file?
Silverdagger
Silverdagger10mo ago
not sure what you mean
vibeman1987
vibeman198710mo ago
Turns out it's not even in the code \o/
Edivado
Edivado10mo ago
Ok strange... opened a PR. Should cover it. It's a bit more complicated than I thought. https://github.com/solidjs/solid-start/pull/1041
vibeman1987
vibeman198710mo ago
weird that it's in the docs, as if it's implemented