Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Add .env support
Browse files Browse the repository at this point in the history
Just create the .env file with VITE_API_HOST in it.
  • Loading branch information
jzgom067 committed Dec 10, 2024
1 parent cd8e8f4 commit c8247c6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/pages/Availability.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default function Availability() {
} else {
try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/create_guest'
import.meta.env.VITE_API_HOST + '/create_guest'
);
if (response.ok) {
const responseData = await response.json();
Expand Down Expand Up @@ -185,7 +185,7 @@ export default function Availability() {

// Proceed with fetch after check_user completes
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/event_details',
import.meta.env.VITE_API_HOST + '/event_details',
{
method: 'POST',
headers: {
Expand Down Expand Up @@ -429,7 +429,7 @@ export default function Availability() {

try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/update_availability',
import.meta.env.VITE_API_HOST + '/update_availability',
{
method: 'POST',
headers: {
Expand Down Expand Up @@ -465,7 +465,7 @@ export default function Availability() {
credentials.guest_password = guestPW;
console.log('SET GUEST STUFF');
} else {
await fetch('http://tomeeto.cs.rpi.edu:8000/create_guest', {
await fetch(import.meta.env.VITE_API_HOST + '/create_guest', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand All @@ -486,7 +486,7 @@ export default function Availability() {
console.log(credentials);
try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/add_availability',
import.meta.env.VITE_API_HOST + '/add_availability',
{
method: 'POST',
headers: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/CreateEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default function CreateEvent() {
} else {
try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/create_guest'
import.meta.env.VITE_API_HOST + '/create_guest'
);
if (response.ok) {
const responseData = await response.json();
Expand Down Expand Up @@ -231,7 +231,7 @@ export default function CreateEvent() {

try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/create_event',
import.meta.env.VITE_API_HOST + '/create_event',
{
method: 'POST',
headers: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const check_user = async (dataToUse) => {
} else {
try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/create_guest'
import.meta.env.VITE_API_HOST + '/create_guest'
);
if (response.ok) {
const responseData = await response.json();
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function Dashboard() {

try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/dashboard_events',
import.meta.env.VITE_API_HOST + '/dashboard_events',
{
method: 'POST',
headers: {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export default function Login() {
console.log('login data? ', data);

try {
const response = await fetch('http://tomeeto.cs.rpi.edu:8000/login', {
console.log(import.meta.env.VITE_API_HOST);
const response = await fetch(import.meta.env.VITE_API_HOST + '/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const check_user = async (dataToUse) => {
} else {
try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/create_guest'
import.meta.env.VITE_API_HOST + '/create_guest'
);
if (response.ok) {
const responseData = await response.json();
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function Result() {
console.log('RANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN');

// First, fetch event details
fetch('http://tomeeto.cs.rpi.edu:8000/event_details', {
fetch(import.meta.env.VITE_API_HOST + '/event_details', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -145,7 +145,7 @@ export default function Result() {
updateEventData(eventDetailsData);

// Next, fetch results using the same credentials
// return fetch('http://tomeeto.cs.rpi.edu:8000/get_results', {
// return fetch(import.meta.env.VITE_API_HOST + '/get_results', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
Expand Down Expand Up @@ -292,7 +292,7 @@ export default function Result() {

try {
const response = await fetch(
'http://tomeeto.cs.rpi.edu:8000/get_results',
import.meta.env.VITE_API_HOST + '/get_results',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -343,7 +343,7 @@ export default function Result() {

// try {
// const response = await fetch(
// 'http://tomeeto.cs.rpi.edu:8000/get_results',
// import.meta.env.VITE_API_HOST + '/get_results',
// {
// method: 'POST',
// headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function Signup() {
};

try {
const response = await fetch('http://tomeeto.cs.rpi.edu:8000/signup', {
const response = await fetch(import.meta.env.VITE_API_HOST + '/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit c8247c6

Please sign in to comment.