Diagnostics

LUM5005: Non-GET method in a static endpoint

A static endpoint exports a method other than GET.

Severity: error · Category: routing and server (5xxx)

Reported by: the route scanner (lumiose dev, lumiose check, lumiose build).

#What it means

static endpoints (the default mode) are prerendered by lumiose build: their GET response is written to a file in dist/client, such as sitemap.xml. A file can only answer GET, so a POST, PUT, PATCH, DELETE, HEAD or OPTIONS export would never run in production.

#Example

ts
// src/routes/api/subscribe/route.ts
export const GET: Endpoint = () => Response.json({ open: true });
export const POST: Endpoint = async (ctx) => {
  await subscribe(await ctx.request.formData());
  return new Response(null, { status: 204 });
};

#How to fix it

Serve the endpoint per request: export const mode = "server"; (or set it on a layout of its folder). Keep the endpoint static only if it serves GET alone.