Serverless function works on localhost but fails after deployment (Gemini API / React / Vite)

Hello Netlify team,

I am encountering a persistent issue with serverless functions after deployment and I would really appreciate your guidance.

Site information

Netlify site name:
(albproject.netlify.app)

Custom domain:
https://www.arabicbank.info

Repository:
(GitHub - AymanEddakrouri/ALB: Arabic Language Bank · GitHub)

Project setup

Framework: React
Build tool: Vite
AI API: Google Gemini
Serverless function file: gemini.ts

Description of the issue

My website deploys successfully and loads normally, but three AI-powered tools on the site stop working after deployment.

These tools send POST requests to a serverless function which calls the Gemini API to process Arabic text and return analysis results.

Observed behavior

  1. Everything works perfectly in my local development environment (localhost).

  2. The same requests also work correctly when tested directly in Google AI Studio.

  3. However, after deployment the tools fail to execute.

Deployment testing

I tested the same project on both platforms:

Netlify
Vercel

In both cases the website deploys successfully, but the three AI tools fail with execution errors.

Affected tools

Smart Academic Paraphraser
Academic Style Auditor
Deep Linguistic Analyzer

Important observations

The frontend loads correctly.
API requests work correctly on localhost.
The failure only occurs after deployment.
The same issue occurs on both Netlify and Vercel deployments.

Because of this behavior I suspect the issue might be related to one of the following:

Serverless runtime configuration
Environment variables
API request handling inside the serverless function

If needed, I can provide the serverless function code (gemini.ts) and the full repository.

Thank you very much for your time and support.

I need anybody please to help me :folded_hands:

I have 3 AI tools on my website, but they don’t work.

Hey @AymanAyman :wave:,
Thanks for reaching out!

We’ve gone ahead and created a support ticket for you, so our team can follow up with you directly via email from the help desk. Our Support crew will be in touch with you by email soon.

Great news: these days anyone can reach out to Netlify Support. First, you can try getting an answer using Ask Netlify, our helpful AI search tool. If your question isn’t answered there, you can submit a ticket using the support form, and we’ll take it from there.

We’re keeping the community around for swapping ideas, sharing tips and tricks, and talking shop with other folks building on the platform — but for support issues, tickets are the way to go.

Thanks for being here, and keep an eye out for that email from us!