Hi all, I’m facing a problem after deploying my React app, which I built using Vite, to Netlify. Everything was running smoothly on my local setup, but now I’m encountering an issue.
Specifically, I get an error saying “slice is not a function” whenever I make API calls on Netlify. Checking the network tab reveals that the API is responding with a 403 error code, indicating that I’m “not subscribed” to the API.
Does anyone have suggestions as to why the API authentication fails on Netlify while it works fine locally? I’m puzzled by the subscription message, especially since my key is supposed to be valid.
sounds like your env variables ain’t set up right on netlify. make sure VITE_API_KEY is added in the site’s env variables on the netlify dashboard, they don’t just transfer from your local .env when you deploy.
I’ve hit this exact issue with RapidAPI and Netlify. Your environment variable probably isn’t getting read during the build. Set it in Netlify’s site settings under Environment variables, but watch out for build-time vs runtime confusion. Since you’re using Vite, VITE_API_KEY should work at build time. I’d add some debugging - log import.meta.env.VITE_API_KEY to see if it’s actually undefined in production. Also check if your RapidAPI subscription expired. That 403 “not subscribed” error usually means your key’s invalid or your subscription lapsed.
Had the same nightmare with RapidAPI on Netlify! Environment variables are part of it, but here’s what usually gets you - RapidAPI has IP restrictions or expects headers that work locally but break in production. Your machine might be whitelisted while Netlify’s servers aren’t. Also check if you’re hitting rate limits during builds - Netlify might spam requests during deployment. Add error handling to log the full response instead of assuming it’s JSON. That 403 probably has specifics about what’s actually wrong with your subscription.