+server.js files can be placed in the same directory as +page files, allowing the same route to be either a page or an API endpoint. To determine which, SvelteKit applies the following rules:
PUT/PATCH/DELETErequests are always handled by+server.jssince they do not apply to pagesGET/POSTrequests are treated as page requests if theacceptheader prioritisestext/html(in other words, it’s a browser page request), else they are handled by+server.js