Skip to content

package doesn't work with wildcard route #66

@Knorway

Description

@Knorway

if you have a controller that handles wildcard path, url includes /trpc/* fallbacks to that route.

// src/trpc/trpc.module.ts
@Module({
  imports: [
    TRPCModule.forRoot({
      autoSchemaFile: 'src/trpc/@generated',
    }),
  ],
})
export class TrpcModule {}

// src/app.controller.ts
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  // this works
  @Get('/hello')
  getHello(): string {
    return this.appService.getHello();
  }

  @All('*')
  all() {
    return '*';
  }
}
curl http://localhost:3000/defaultRouter.HomeScreenQuery
-> *

using middleware or router of underlying framework directly has no issues with nest's wildcard

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  // this works
  app.use('/use', (req, res, next) => {
    res.send('/use');
  });

  // this works as well
  const srv = app.getHttpAdapter().getInstance();
  srv.get('/get', (req, res) => {
    res.send('/get');
  });

  await app.listen(3000);
}

any workarounds would be much appreciated!

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