Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make the vite react app run on http://localhost:3000 insted of http://127.0.0.1:5173

Im trying to use google oauth with my vite react app but i dont know why the Authorized JavaScript origins is not working if i give http://127.0.0.1:5173 as the URIs but its working for http://localhost:3000 so i want to make my vite react app run on http://localhost:3000 insted of http://127.0.0.1:5173 when i type npm run dev and press o (to open the page on browser).

I even tried to make some changes to the vite.config.js but still not working below is the code

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    host: "localhost",
    port: 3000,
  },
});

In package.json file this is the change that i have made in package.json file

someone please help me with this.

Tried this

like image 951
Gagan Avatar asked Dec 31 '25 15:12

Gagan


1 Answers

vite.config.ts

import dns from 'dns';

// localhost part
dns.setDefaultResultOrder('verbatim');

export default defineConfig({
  server: {
    port: 3000,
  },
});
like image 85
Konrad Linkowski Avatar answered Jan 02 '26 09:01

Konrad Linkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!