@@ -4,6 +4,9 @@ import { toast } from "react-toastify";
44import { Eye , EyeOff } from "lucide-react" ;
55import SetPassword from "./SetPassword" ; // Adjust path
66
7+ const BASE_URL = ( import . meta. env ?. VITE_SIP || "http://localhost" ) . replace ( / \/ + $ / , "" ) ;
8+ const API = `${ BASE_URL } ` ;
9+
710const Login = ( { setIsAuthenticated, setUser } ) => {
811 const navigate = useNavigate ( ) ;
912 const location = useLocation ( ) ;
@@ -67,7 +70,7 @@ const Login = ({ setIsAuthenticated, setUser }) => {
6770 setLoading ( true ) ;
6871
6972 try {
70- const response = await fetch ( "http://127.0.0.1: 5000/login" , {
73+ const response = await fetch ( ` ${ API } : 5000/login` , {
7174 method : "POST" ,
7275 headers : { "Content-Type" : "application/json" } ,
7376 body : JSON . stringify ( { email, password } ) ,
@@ -112,7 +115,7 @@ const Login = ({ setIsAuthenticated, setUser }) => {
112115
113116 const handleGoogleLogin = async ( ) => {
114117 try {
115- const response = await fetch ( "http://127.0.0.1: 5000/auth/google" ) ;
118+ const response = await fetch ( ` ${ API } : 5000/auth/google` ) ;
116119 const data = await response . json ( ) ;
117120 if ( data . authorization_url ) {
118121 window . location . href = data . authorization_url ;
@@ -134,7 +137,7 @@ const Login = ({ setIsAuthenticated, setUser }) => {
134137
135138 const handleGitHubLogin = async ( ) => {
136139 try {
137- window . location . href = "http://127.0.0.1:5000/ auth/github" ;
140+ window . location . href = ` ${ API } / auth/github` ;
138141 } catch ( error ) {
139142 toast . error ( "Erreur GitHub OAuth" , {
140143 position : "top-right" ,
0 commit comments