Vite React app stuck trying to fetch from old localhost API (ERR_CONNECTION_REFUSED) after migrating to Supabase
15:38 22 Mar 2026

Title
Vite React app stuck trying to fetch from old localhost API (ERR_CONNECTION_REFUSED) after migrating to Supabase

Body
I am migrating my React + TypeScript (Vite) project's backend from a local server (http://localhost:8080) to a Supabase backend.
I have completely replaced axios with the @supabase/supabase-js client and removed all references to the old localhost URL in my codebase. However, my browser is still attempting to make GET requests to the old local server, causing my app to break.

The Error in the Console:
The console shows the following errors repeatedly, and strangely, they point to a minified build file (index-DiTxxjc7.js), even though I am running the development server:

Plaintext
Failed to load resource: net::ERR_CONNECTION_REFUSED localhost:8080/food:1
GET http://localhost:8080/food net::ERR_CONNECTION_REFUSED index-DiTxxjc7.js:11
My Current Code:
Here is how I set up the Supabase client (src/supabase.ts):

TypeScript

import { createClient } from '@supabase/supabase-js';

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseKey = import.meta.env.VITE_SUPABASE_ANON_KEY;

export const supabase = createClient(supabaseUrl, supabaseKey);

And here is the custom hook using @tanstack/react-query where I make the request (src/hooks/useFoodData.tsx):

Typescript

import { useQuery } from "@tanstack/react-query";
import { supabase } from "../supabase";
import type { FoodData } from "../interface/FoodData";

const fetchData = async (): Promise => {
  const { data, error } = await supabase.from('food').select('*');
  if (error) throw new Error(error.message);
  return data as FoodData[];
};

export function useFoodData() {
  const query = useQuery({
    queryFn: fetchData,
    queryKey: ['food-data'],
    retry: 2
  });
  return { ...query, data: query.data };
}

What I have already tried (Troubleshooting):
To ensure this isn't a simple caching issue or a leftover string, I have done the following:

Global Search: Ran a global search in VS Code for 8080 and localhost. 0 results found.

Environment Variables: Checked all .env files. There are no old URLs left.

Hard Refresh & Incognito: Tested in a completely new Incognito window and used Hard Refresh. The error persists.

Deleted Build Folder: Manually deleted the dist folder to ensure it's not serving an old production build.

Cleared Vite Cache: Stopped the server and ran npm run dev -- --force to clear the .vite dependency cache inside node_modules.

Correct Port: Ensured I am accessing the app strictly via Vite's default http://localhost:5173 and not through VS Code Live Server.

Despite all of this, the application still acts as if axios.get('http://localhost:8080/food') is written somewhere in the code. Why is a minified file (index-DiTxxjc7.js) still executing this old request, and how can I completely purge this ghost code from my Vite/React environment?

javascript jquery reactjs rest