Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nexus returns status code 500 when JWT is expired #10

Open
sreuter opened this issue Sep 13, 2020 · 2 comments
Open

Nexus returns status code 500 when JWT is expired #10

sreuter opened this issue Sep 13, 2020 · 2 comments

Comments

@sreuter
Copy link

sreuter commented Sep 13, 2020

Nexus Report

{
  "node": "v12.14.0",
  "os": {
    "platform": "darwin",
    "release": "18.7.0"
  },
  "nexus": "^0.26.1",
  "plugins": [
    "nexus-plugin-auth0",
    "nexus-plugin-user-context",
    "nexus-plugin-shield",
    "nexus-plugin-prisma"
  ],
  "otherDependencies": {
    "@types/jwt-decode": "^2.2.1",
    "jwt-decode": "^2.2.0",
    "typescript": "^3.7.5"
  },
  "devDependencies": {
    "@types/jest": "^26.0.8",
    "jest": "^26.2.2",
    "nodemon": "^2.0.2",
    "prettier": "^2.0.5",
    "ts-jest": "^26.1.4",
    "ts-node": "^8.6.2"
  },
  "hasAppModule": true,
  "packageManager": "yarn",
  "errorsWhileGatheringReport": {
    "gettingLayout": null,
    "gettingPluginManifests": null
  }
}

Description

Nexus returns 500 with this plugin whenever a JWT is expired. It should return a 401 instead, so that a client can react according and refresh its token.

@haysclark
Copy link

@sreuter This Nexus plugin simply wraps jwks-rsa, so you might need to create an issue in that library and then follow up when a fix is released.

@sreuter
Copy link
Author

sreuter commented Sep 16, 2020

I think this is more about the missing ability (or knowledge) of being able to control the status code being sent from within a nexus plugin. I've solved this for now by simply adding a express middleware to nexus via server.express.use(). Might also be possible via https://nexusjs.org/api/nexus/schema#example-simple-middlewares, but felt less appropriate as its not really related to the schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants