Skip to content

Commit 8eb66b7

Browse files
author
EL BADOURI Youssef
committed
removed the localhost
1 parent 4942ec9 commit 8eb66b7

File tree

10 files changed

+33
-12
lines changed

10 files changed

+33
-12
lines changed

backend/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ transformers
1919
torch
2020
flask_sqlalchemy
2121
semgrep
22-
checkov
22+
check

frontend/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_SIP=http://localhost

frontend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.env.development.local
1818
.env.test.local
1919
.env.production.local
20+
.env
2021

2122
npm-debug.log*
2223
yarn-debug.log*

frontend/src/pages/AdminDashboard.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
ArrowPathIcon,
88
ExclamationTriangleIcon,
99
} from "@heroicons/react/24/outline";
10-
10+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
11+
const API = `${BASE_URL}/api`;
1112
// Utility function for smooth number animation
1213
const useCountUp = (end, duration = 2000) => {
1314
const [count, setCount] = useState(0);
@@ -62,7 +63,7 @@ const AdminDashboard = () => {
6263

6364
const fetchAdminStats = async () => {
6465
try {
65-
const response = await fetch("http://127.0.0.1:5000/api/admin-stats", {
66+
const response = await fetch(`${API}/admin-stats`, {
6667
method: "GET",
6768
headers: {
6869
Authorization: `Bearer ${localStorage.getItem("token")}`,

frontend/src/pages/AllInOne.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
DocumentDuplicateIcon,
1111
} from "@heroicons/react/24/outline";
1212

13+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
14+
const API = `${BASE_URL}`;
15+
1316
// Fonction pour convertir les données Checkov en texte lisible avec fichier en premier
1417
const formatCheckovText = (data, filename) => {
1518
if (!data || !data.failed_checks) return "Aucune vérification disponible pour ce fichier.";
@@ -44,7 +47,7 @@ const AllInOne = ({ userId }) => {
4447

4548
setLoading(true);
4649
try {
47-
const response = await fetch("http://127.0.0.1:5000/full-scan", {
50+
const response = await fetch(`${API}/full-scan`, {
4851
method: "POST",
4952
headers: {
5053
"Content-Type": "application/json",

frontend/src/pages/Configs.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { Link, useNavigate } from "react-router-dom";
55
import LoadingLogo from "../components/LoadingLogo";
66
import loadingVideo from "../assets/loading.mp4";
77

8+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
9+
const API = `${BASE_URL}`;
10+
811
const Configs = () => {
912
const [configs, setConfigs] = useState([]);
1013
const [loading, setLoading] = useState(true);
@@ -16,7 +19,7 @@ const Configs = () => {
1619
setLoading(true);
1720
setError("");
1821
try {
19-
const response = await fetch("http://127.0.0.1:5000/github/repo-configs", {
22+
const response = await fetch(`${API}:5000/github/repo-configs`, {
2023
method: "GET",
2124
headers: { Authorization: `Bearer ${localStorage.getItem("token")}` },
2225
});

frontend/src/pages/Login.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { toast } from "react-toastify";
44
import { Eye, EyeOff } from "lucide-react";
55
import SetPassword from "./SetPassword"; // Adjust path
66

7+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
8+
const API = `${BASE_URL}`;
9+
710
const 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",

frontend/src/pages/PoliciesGenerator.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
66
import { dracula } from "react-syntax-highlighter/dist/esm/styles/prism";
77
import ReactMarkdown from "react-markdown";
88

9+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
10+
const API = `${BASE_URL}`;
11+
912
const PoliciesGenerator = () => {
1013
const location = useLocation();
1114
const selectedFiles = location.state?.selectedFiles || [];
@@ -34,7 +37,7 @@ const PoliciesGenerator = () => {
3437

3538
setIsLoading(true);
3639
try {
37-
const response = await fetch("http://127.0.0.1:5000/t5", {
40+
const response = await fetch(`${API}:5000/t5`, {
3841
method: "POST",
3942
headers: {
4043
"Content-Type": "application/json",

frontend/src/pages/Register.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React, { useState } from "react";
22
import { useNavigate, Link } from "react-router-dom";
33
import { toast } from "react-toastify";
44

5+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
6+
const API = `${BASE_URL}`;
7+
58
const Register = () => {
69
const navigate = useNavigate();
710
const [step, setStep] = useState(1); // 1: Register form, 2: Verify code
@@ -13,7 +16,7 @@ const Register = () => {
1316
const handleRegister = async (e) => {
1417
e.preventDefault();
1518
try {
16-
const response = await fetch("http://127.0.0.1:5000/register", {
19+
const response = await fetch(`${API}/register`, {
1720
method: "POST",
1821
headers: { "Content-Type": "application/json" },
1922
body: JSON.stringify({ name, email, password }),
@@ -46,7 +49,7 @@ const Register = () => {
4649
const handleVerifyCode = async (e) => {
4750
e.preventDefault();
4851
try {
49-
const response = await fetch("http://127.0.0.1:5000/verify-code", {
52+
const response = await fetch(`${API}:5000/verify-code`, {
5053
method: "POST",
5154
headers: { "Content-Type": "application/json" },
5255
body: JSON.stringify({ email, code }),

frontend/src/pages/SetPassword.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React, { useState } from "react";
22
import { useNavigate } from "react-router-dom";
33
import { toast } from "react-toastify";
44

5+
const BASE_URL = (import.meta.env?.VITE_SIP || "http://localhost").replace(/\/+$/, "");
6+
const API = `${BASE_URL}`;
7+
58
const SetPassword = ({ user, setIsAuthenticated, setUser }) => {
69
const navigate = useNavigate();
710
const [password, setPassword] = useState("");
@@ -23,7 +26,7 @@ const SetPassword = ({ user, setIsAuthenticated, setUser }) => {
2326
}
2427

2528
try {
26-
const response = await fetch("http://127.0.0.1:5000/set-password", {
29+
const response = await fetch(`${API}:5000/set-password`, {
2730
method: "POST",
2831
headers: {
2932
"Content-Type": "application/json",

0 commit comments

Comments
 (0)