diff --git a/.env.exemple b/.env.exemple new file mode 100644 index 0000000..3452b5c --- /dev/null +++ b/.env.exemple @@ -0,0 +1 @@ +VITE_API_URL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index f52343a..bd7187d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ dist-ssr *storybook.log storybook-static + +.env \ No newline at end of file diff --git a/src/utils/getUser.js b/src/utils/getUser.js index 6826525..24297ca 100644 --- a/src/utils/getUser.js +++ b/src/utils/getUser.js @@ -1,6 +1,6 @@ export default async function getUser() { try { - const res = await fetch('http://localhost:8000/api/me', { + const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/me`, { method: 'GET', credentials: 'include', headers: { diff --git a/src/utils/getXSRF.js b/src/utils/getXSRF.js index 1bed25f..0c78e40 100644 --- a/src/utils/getXSRF.js +++ b/src/utils/getXSRF.js @@ -1,5 +1,5 @@ export default async function getXSRFToken() { - const response = await fetch('http://localhost:8000/sanctum/csrf-cookie', { + const response = await fetch(`http://${import.meta.env.VITE_API_URL}/sanctum/csrf-cookie`, { method: 'GET', credentials: 'include' }); diff --git a/src/utils/login.js b/src/utils/login.js index a08151b..161268c 100644 --- a/src/utils/login.js +++ b/src/utils/login.js @@ -4,7 +4,7 @@ export default async function login(email, password) { const csrfToken = await getXSRFToken(); try { - const response = await fetch('http://localhost:8000/api/users/login', { + const response = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/login`, { method: 'POST', credentials: 'include', headers: { diff --git a/src/utils/register.js b/src/utils/register.js index 1612bf8..313df77 100644 --- a/src/utils/register.js +++ b/src/utils/register.js @@ -4,7 +4,7 @@ export default async function register(email, password, name, lastname) { const csrfToken = await getXSRFToken(); try { - const response = await fetch('http://localhost:8000/api/users/register', { + const response = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/register`, { method: 'POST', credentials: 'include', headers: {