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

Commit

Permalink
fix: revert to localhost instead of distant api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpinet committed Apr 28, 2024
1 parent 0e59936 commit d30f7aa
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion front/www/js/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
fetch(`${baseUrl}/api/achievements`, {
method: "GET",
headers: {
Expand Down
4 changes: 2 additions & 2 deletions front/www/js/ai-game-mobile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");

socket.on("connect", () => {
console.log("Connected to server.");
Expand Down Expand Up @@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", async () => {
socket.on("gameCreated", (game) => {
gameId = game._id;
initializeGame(game);
//const baseUrl = "https://quanridor.ps8.academy";
//const baseUrl = window.location.origin;
//window.location.href = `${baseUrl}/ai-game.html?id=` + gameId;

// Setting the game info display
Expand Down
4 changes: 2 additions & 2 deletions front/www/js/ai-game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");

socket.on("connect", () => {
console.log("Connected to server.");
Expand Down Expand Up @@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", async () => {
socket.on("gameCreated", (game) => {
gameId = game._id;
initializeGame(game);
//const baseUrl = "https://quanridor.ps8.academy";
//const baseUrl = window.location.origin;
//window.location.href = `${baseUrl}/ai-game.html?id=` + gameId;

// Setting the game info display
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/bot-choice-mobile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");

const AI0 = document.getElementById("AI0");
const AI1 = document.getElementById("AI1");
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/bot-choice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");

const AI0 = document.getElementById("AI0");
const AI1 = document.getElementById("AI1");
Expand Down
6 changes: 3 additions & 3 deletions front/www/js/chatsocket.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if (/Mobi|Android/i.test(navigator.userAgent)) {
document.addEventListener("DOMContentLoaded", function () {
const permanent_socket = io("https://quanridor.ps8.academy/api/social");
const permanent_socket2 = io("https://quanridor.ps8.academy/api/game");
const permanent_socket = io("/api/social");
const permanent_socket2 = io("/api/game");

const token = localStorage.getItem("token");
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
fetch(`${baseUrl}/api/users`, {
method: "GET",
headers: {
Expand Down
10 changes: 5 additions & 5 deletions front/www/js/friend-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -------------------------- FRIENDS --------------------------

const socket2 = io("https://quanridor.ps8.academy/api/game");
const socket2 = io("/api/game");
const friendIdToUsername = {};
let currentSelectedFriendId = null;
let isChatVisible = false;
Expand All @@ -12,7 +12,7 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
fetch(`${baseUrl}/api/users`, {
method: "GET",
headers: {
Expand Down Expand Up @@ -45,7 +45,7 @@ document.addEventListener("DOMContentLoaded", function () {
let currentUserId;

document.addEventListener("DOMContentLoaded", function () {
const socket = io("https://quanridor.ps8.academy/api/social");
const socket = io("/api/social");

const sendMessageButton = document.getElementById("send");
const messageInput = document.getElementById("message-input");
Expand All @@ -57,7 +57,7 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;

const fetchFriendDetails = (friendId) => {
return fetch(`${baseUrl}/api/users/${friendId}`, {
Expand Down Expand Up @@ -180,7 +180,7 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
fetch(`${baseUrl}/api/users`, {
method: "GET",
headers: {
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/game-retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Function to retrieve games and update the UI
async function retrieveGamesInProgress() {
try {
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
const response = await fetch(
`${baseUrl}/api/game?multiple=true&withStatus=1`,
{
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ document.addEventListener("DOMContentLoaded", function () {

async function retrieveLeaderboard() {
try {
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
const token = localStorage.getItem("token");
fetch(`${baseUrl}/api/users`, {
method: "GET",
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Get the values from the form
const username = form.querySelector('input[name="username"]').value;
const password = form.querySelector('input[name="password"]').value;
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;

// Construct the JSON object to send
const data = { username, password };
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/online-game-mobile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");
const urlParams = new URLSearchParams(window.location.search);
let roomId = urlParams.get("roomId");
socket.on("connect", () => {
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/online-game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const socket = io("https://quanridor.ps8.academy/api/game");
const socket = io("/api/game");
const urlParams = new URLSearchParams(window.location.search);
let roomId = urlParams.get("roomId");
socket.on("connect", () => {
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/signup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;

document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("form");
Expand Down
2 changes: 1 addition & 1 deletion front/www/js/user-info-retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ document.addEventListener("DOMContentLoaded", function () {
console.log("No token found in local storage.");
return;
}
const baseUrl = "https://quanridor.ps8.academy";
const baseUrl = window.location.origin;
fetch(`${baseUrl}/api/users`, {
method: "GET",
headers: {
Expand Down

0 comments on commit d30f7aa

Please sign in to comment.