Can't get a reponse from a Serverless Function using Vite

I’m just trying to test Serverless functions with React on Netlify but I’m not getting a response when I use Vite for React. Essentially what I did was:

  1. Created a new React application (npm create-react-app)
  2. Installed netlify-cli as a local dependacy
  3. Created a functions folder in the root directory with a javascript file called “data”:
exports.handler = async (event, context) => {
  return {
    statusCode: 200,
    body: "Testing",
  };
};
  1. Created the netlify.toml in root directory:
[build]
  functions = "./functions"
  1. Ran npn run netlify, went to the URL of: http://localhost:8888/.netlify/functions/data and everything works!

However, if I use Vite to create my react app, I get this:

Request from ::1: GET /.netlify/functions/data
Response with status 404 in 1 ms.

I followed the exact same steps. The only difference is I used Vite instead of create-react-app. Does anyone know how to solve this problem?

Hi @Zvoks,

Thanks for reaching out!

Could you provide us with a url of your site (such as example.netlify.app)? This will help us investigate the issue.

Additionally, you can read about creating serverless functions here: