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) { if (currentUser) {
console.log('Logged in. Proceed to add to favorites.'); 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", method: "POST",
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View file

@ -42,7 +42,7 @@ export default {
const currentUser = JSON.parse(sessionStorage.getItem('current_user')); const currentUser = JSON.parse(sessionStorage.getItem('current_user'));
if (currentUser && currentUser.id) { 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) { if (!response.ok) {
throw new Error('Failed to fetch favorites'); throw new Error('Failed to fetch favorites');

View file

@ -98,7 +98,7 @@ export default {
login() { login() {
if (this.input.email !== '' && this.input.password !== '') { if (this.input.email !== '' && this.input.password !== '') {
console.log('Authenticated: Checking with Backend'); 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", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -138,7 +138,7 @@ export default {
client_id: client_id:
import.meta.env.VITE_CLIENT_ID, import.meta.env.VITE_CLIENT_ID,
scope: "email profile openid", 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 => { callback: response => {
if (response.code) { if (response.code) {
this.sendCodeToBackend(response.code); this.sendCodeToBackend(response.code);
@ -153,7 +153,7 @@ export default {
const headers = { const headers = {
Authorization: code 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; const userDetails = response.data;
console.log("User Details:", userDetails); console.log("User Details:", userDetails);
this.userDetails = userDetails; this.userDetails = userDetails;

View file

@ -108,7 +108,7 @@ import eyeNotLooking from '../../icons/Material/eye-not-looking.svg';
register() { register() {
if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) { if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) {
console.log('Authenticated: Checking with Backend'); 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", method: "POST",
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View file

@ -97,7 +97,7 @@ const display_items = [
function logout() { function logout() {
if (sessionStorage.getItem('current_user')){ if (sessionStorage.getItem('current_user')){
console.log('loging out...'); 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" method: "GET"
}).then(()=>{ }).then(()=>{
console.log('loged out'); console.log('loged out');