MERN Stack with Auth0: Calling API resource from react app gives 401 Unauthorized error

My MERN stack app works like this:

  1. User logs in with google account (Auth0)
  2. User fills up a form and clicks submit. Post request is sent to API with Bearer token and data
  3. ExpressJs API on the backend validates JWT. If it is valid, the data gets saved in database

Here, I’m able to login using google. However when I fill up the form and click submit, I’m getting unauthorized error with a status code of 401. The exact error I’m seeing is ,

"InvalidTokenError: Invalid URL
at D:\Projects\2022\MV\mvjuly\node_modules\express-oauth2-jwt-bearer\dist\index.js:271:19
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async D:\Projects\2022\MV\mvjuly\node_modules\express-oauth2-jwt-bearer\dist\index.js:354:24"

Hi @sachinottawa,

Welcome to the Auth0 Community!

Do you have an example of the token?