Skip to content

Wildcard Route Issue in Koa-Router v13 #196

Open
@Caringor

Description

Environment

  • Package Name: koa-router

  • Version: v13.x (latest)

  • Node.js Version: v22.12.0

  • Operating System: macOS 14.4.1

Summary

After upgrading to koa-router v13 from v12, I encountered an issue with wildcard routes. Specifically, routes defined with * (e.g., :proxyPath*) no longer work as expected.

Steps to Reproduce

  1. Define a route using a wildcard parameter in the router setup:

    const Router = require('koa-router');
    const router = new Router();
    
    router.get(`/api/:token/:proxyPath*`, async (ctx) => {
        ctx.body = { message: 'Wildcard route works!' };
    });
    
  2. Start the server and send a request matching the route (e.g., /api/123/some/path/to/resource).

  3. Observe the error when running the application:

    TypeError: Missing parameter name at 49: https://git.new/pathToRegexpError
    

Expected Behavior

In koa-router v12 and earlier versions, the route defined with * correctly captured the remaining path segments. The server processed the request without errors.

Actual Behavior

With koa-router v13, the application throws the following error when using a wildcard route:

TypeError: Missing parameter name at 49: https://git.new/pathToRegexpError

Additional Information

  • This behavior change does not seem to be documented in the release notes.

  • I’ve reviewed the migration guide but couldn’t find details regarding this specific change or deprecation of wildcard support.

Questions

  1. Is this a bug introduced in v13, or was the behavior of wildcard parameters intentionally changed or removed?

  2. How can I achieve similar functionality (capturing all remaining path segments) in koa-router v13?

  3. If this is not supported in v13, is there an alternative approach or a recommended workaround?

Thank you for your assistance!

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions