mirror of
https://gitlab.com/little-lines/frontend.git
synced 2024-11-21 19:16:53 +00:00
Use backend URL from .env
This commit is contained in:
parent
f8813411ae
commit
b922df3766
5 changed files with 9 additions and 7 deletions
|
@ -368,7 +368,9 @@ export default {
|
|||
if (currentUser) {
|
||||
console.log('Logged in. Proceed to add to favorites.');
|
||||
|
||||
fetch("https://little-lines-backend.techtransthai.org/api/favorites/create", {
|
||||
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/favorites/create`, {
|
||||
// fetch("https://little-lines-backend.techtransthai.org/api/favorites/create", {
|
||||
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -42,7 +42,7 @@ export default {
|
|||
const currentUser = JSON.parse(sessionStorage.getItem('current_user'));
|
||||
|
||||
if (currentUser && currentUser.id) {
|
||||
const response = await fetch(`https://little-lines-backend.techtransthai.org/api/favorites/${currentUser.id}`);
|
||||
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL}/api/favorites/${currentUser.id}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch favorites');
|
||||
|
|
|
@ -98,7 +98,7 @@ export default {
|
|||
login() {
|
||||
if (this.input.email !== '' && this.input.password !== '') {
|
||||
console.log('Authenticated: Checking with Backend');
|
||||
fetch(`https://little-lines-backend.techtransthai.org/api/users/login`, {
|
||||
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/users/login`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -138,7 +138,7 @@ export default {
|
|||
client_id:
|
||||
import.meta.env.VITE_CLIENT_ID,
|
||||
scope: "email profile openid",
|
||||
redirect_uri: "https://little-lines-backend.techtransthai.org/api/users/googleAuth/callback",
|
||||
redirect_uri: `${import.meta.env.VITE_BACKEND_URL}/api/users/googleAuth/callback`,
|
||||
callback: response => {
|
||||
if (response.code) {
|
||||
this.sendCodeToBackend(response.code);
|
||||
|
@ -153,7 +153,7 @@ export default {
|
|||
const headers = {
|
||||
Authorization: code
|
||||
};
|
||||
const response = await axios.post("https://little-lines-backend.techtransthai.org/api/users/googleAuth", null, { headers });
|
||||
const response = await axios.post(`${import.meta.env.VITE_BACKEND_URL}/api/users/googleAuth`, null, { headers });
|
||||
const userDetails = response.data;
|
||||
console.log("User Details:", userDetails);
|
||||
this.userDetails = userDetails;
|
||||
|
|
|
@ -108,7 +108,7 @@ import eyeNotLooking from '../../icons/Material/eye-not-looking.svg';
|
|||
register() {
|
||||
if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) {
|
||||
console.log('Authenticated: Checking with Backend');
|
||||
fetch("https://little-lines-backend.techtransthai.org/api/users/create", {
|
||||
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/users/create`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
@ -97,7 +97,7 @@ const display_items = [
|
|||
function logout() {
|
||||
if (sessionStorage.getItem('current_user')){
|
||||
console.log('loging out...');
|
||||
fetch(`https://little-lines-backend.techtransthai.org/api/users/logout`, {
|
||||
fetch(`${import.meta.env.VITE_BACKEND_URL}/api/users/logout`, {
|
||||
method: "GET"
|
||||
}).then(()=>{
|
||||
console.log('loged out');
|
||||
|
|
Loading…
Reference in a new issue