#GET request returning 404, but controller seems registered properly? Any ideas what I'm missing?

1 messages · Page 1 of 1 (latest)

turbid mesa
#
@Controller('migrations')
export class DbMigrationsController {
  @Get('trigger')
  public async triggerMigrations(
  controllers: [DbMigrationsController],
  app.setGlobalPrefix('/apis/super-service');

Yet it is throwing "Cannot GET /apis/super-service/migrations/trigger",

#

it's odd, it appearsthat it has been mapped in the nest logs, the whole route

#

why am I getting a 404 then hmm

trail saddle
#

show us the request you've made itself

#

and the mapped route in the logs

turbid mesa
#

well this is an odd one as fuck.

#

http://localhost:3500/apis/super-service/migrations

#

I made a simple test endpoint in the migrations controller

#
  public async test() {
    return;
  }```
#

I also have a "NotFound" exception handler globally, but the logs show no activity happening in that controller for that request really really weird

#
    console.log(`Super Service listening on port ${process.env.PORT ?? 3500}`);
  });```
#

I have a app.use('/apis/super-service/health', (req: Request, res: Response) => { return res.status(200).send(); });

#

and this one works --- it's only the registered controller that does not work

#

http://localhost:3500/apis/super-service/health returns 200

#

in 5 years of using nestjs I don't think I've ever been more confused

#

oh nevermind, the not found exception filter works

#

it does indeed catch the error

#

I've deleted my dist folder, checked my import statements for every decorator

turbid mesa
#

yes

trail saddle
#

did you supply that version in your request?

#

which kind of versioning is that?

turbid mesa
#
  app.enableVersioning({
    type: VersioningType.HEADER,
    header: 'yeo-api-version',
    defaultVersion: configService.get('CURRENT_VERSION'),
  });```
#

that config will return 5.0

#

but --- it has a default version

#

shouldn't this work with the default version header?

#

this is a good time to say I haven't used NestJS versioning before

trail saddle
#

there you said that the request must have the header yeo-api-version, if you didn't supply that in your request you'll get 404

#

defaultVersion is the default version on all controllers

turbid mesa
#

thanks, I didn't know that

#

apparently it doesn't apply to graphql resolvers 😄

#

I'll just remove versioning for now