Skip to content

Architecture: Next.js API Route Handler restricts Elysia endpoints to GET requests only #2

Description

@TaiChi112

Context

In app/api/[[...slugs]]/route.ts, the Next.js catch-all route handler is used as a proxy to forward incoming HTTP requests to the underlying Elysia application (src/server/app).

Problem

The Next.js route handler only exports the GET method:

export const GET = handler;

Because Next.js strictly requires explicit exports for each supported HTTP method, Next.js will intercept and block any POST, PUT, PATCH, or DELETE requests before they ever reach Elysia, automatically returning a 405 Method Not Allowed.

For a full-stack boilerplate/kit, this fundamentally breaks the ability to create, update, or delete resources through the API.

Recommended Solution

Export all standard HTTP methods from the route handler so Elysia can handle the routing properly for all types of requests.

Example Fix:

export const GET = handler;
export const POST = handler;
export const PUT = handler;
export const PATCH = handler;
export const DELETE = handler;
export const OPTIONS = handler;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions