Use backend URL from .env

This commit is contained in:
Late Night Defender 2024-06-03 18:04:01 +07:00
parent f8813411ae
commit b922df3766
5 changed files with 9 additions and 7 deletions

View file

@ -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',

View file

@ -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');

View file

@ -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;

View file

@ -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',

View file

@ -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');