Hi - first-time poster here!
I'm facing a very strange problem where my JWT tokens all of the sudden are invalid. But only in my production environment, not local, not staging (this env is basically a mirror of prod).
Everything was working for a bit more than a month, but starting a few days ago, I encountered the "invalid signature" error. I haven't touched this part of the system since creating it, so, I'm very confused. And now I've struggled with this for some time, and I cannot fix it, or reproduce it...
I've read related posts, but they all boil down to signing something incorrectly, or the env vars being null. I checked this and none of these are the case.
This happened from one day to the next, and as mentioned, I've not touched this part of the system.
This is the full error log from my NestJS service:
- attached image
This is the error I log out on Sentry:
{
message: invalid signature,
name: JsonWebTokenError,
stack: [Filtered]
}
This is how I sign:
const token = this.jwtService.sign(payload, {
secret: this.configService.get("JWT_SECRET"),
expiresIn: `${+this.configService.get("JWT_EXPIRATION_TIME")}s`,
});
This is how I verify:
const payload: TokenPayload = this.jwtService.verify(token, {
secret: this.configService.get("JWT_SECRET"),
});
Some help would be greatly appreciated!