Skip to content

OPTIONS header doesn't work #2

@OmgImAlexis

Description

@OmgImAlexis

If you use router.allowedMethods() before koa404Handler you get a 404 returned for all OPTIONS requests. Maybe something needs to be added to the docs or something may need to be changed to allow it to work in any order.

I'd suggest just checking if the Allow header is set as that means it'll be an OPTIONS request.

// Mount the app's defined and nested routes
app.use(router.routes());

// 404 handler
app.use(koa404Handler);

// Options method
app.use(router.allowedMethods({
    throw: true,
    notImplemented: () => new Boom.notImplemented(),
    methodNotAllowed: () => new Boom.methodNotAllowed()
}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions