0

I am working on a web platform using Nuxt 3 and Notion as my backend through the official API. I use it through this SDK : https://www.npmjs.com/package/@notionhq/client Everything is working great on localhost:3000 but when I deploy my website to Vercel, I have this error message :

WARN @notionhq/client warn: request fail { code: 'unauthorized', message: 'API token is invalid.' }

It is really strange because I have the same NOTION_API_KEY (as localhost) inside my .env...

Here is my package.json :

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "@nuxtjs/supabase": "^0.1.16",
    "@nuxtjs/tailwindcss": "^5.1.2",
    "@tailwindcss/forms": "^0.5.2",
    "@tailwindcss/typography": "^0.5.2",
    "nuxt": "3.0.0-rc.4",
    "sass": "^1.53.0",
    "sass-loader": "^10.3.0"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.1.1",
    "@fortawesome/free-brands-svg-icons": "^6.1.1",
    "@fortawesome/free-regular-svg-icons": "^6.1.1",
    "@fortawesome/free-solid-svg-icons": "^6.1.1",
    "@fortawesome/vue-fontawesome": "^3.0.1",
    "@headlessui/vue": "^1.6.4",
    "@heroicons/vue": "^1.0.6",
    "@notionhq/client": "^2.2.1",
    "highlight.js": "^11.6.0",
    "vue-gtag-next": "^1.14.0"
  }
}

Have you ever encountered this scenario?

My Notion Token is invalid on production but working on localhost.

kissu
  • 40,416
  • 14
  • 65
  • 133
  • Inside your `.env` file on production or inside the environment variables on the dashboard? Not the same, should be the last one. As shown here: https://stackoverflow.com/a/67389035/8816585 – kissu Nov 03 '22 at 01:45
  • Thank you @kissu ! Do you know why my other variables (Google Analytics tracking + Supabase) are OK in production without having to put them in the Vercel dashboard ? – Thibaud d'Arros Nov 03 '22 at 09:15
  • They are maybe hardcoded somewhere? Or you do have a fallback string matching the env variable? Docker/DevOps/CI pipeline, there can be various points where you could get those. Because there is no magic usually, if it's not there it will not work. Is your issue solved? – kissu Nov 03 '22 at 09:18

0 Answers0