From 40b0855ca509f0351f7881f4b34675da1d5e9bb3 Mon Sep 17 00:00:00 2001 From: matiasc18 Date: Tue, 24 Mar 2026 15:48:23 -0400 Subject: [PATCH] EnterCode Signup working - After fetching join code in EnterCode(), it sets networkId attribute on "signup-" (Signup.js) - Signup.js then includes the attribute in the call body - Modified all calls to /signout, /profile, /login, /signup to be prefixed by '/auth' - Added '/auth' to vite config file - Modified final "else if" statement in .attr in quill.js to return `this.getAttribute(arg1)` instead of `this.getAttribute("")` --- src/Home/AuthPage/EnterCode.js | 4 +++- src/Home/AuthPage/Login.js | 2 +- src/Home/AuthPage/Signup.js | 4 +++- src/index.js | 4 ++-- src/public/_/code/quill.js | 2 +- vite.config.ts | 20 ++++---------------- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/Home/AuthPage/EnterCode.js b/src/Home/AuthPage/EnterCode.js index 8a41b29..c3a9664 100644 --- a/src/Home/AuthPage/EnterCode.js +++ b/src/Home/AuthPage/EnterCode.js @@ -82,13 +82,15 @@ class EnterCode extends Shadow { console.log("submit") const res = await fetch(`${util.HOST}/auth/joincode`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', "Accept": "application/json" }, body: JSON.stringify({ code: this.$("input").value }) }); if (res.ok) { console.log("got join code succ") this.attr("codeaccepted", "true") + let { networkId } = await res.json() + $("signup-").attr("networkid", networkId) } else { const { error } = await res.json(); console.error(error) diff --git a/src/Home/AuthPage/Login.js b/src/Home/AuthPage/Login.js index e08b8d3..b17e082 100644 --- a/src/Home/AuthPage/Login.js +++ b/src/Home/AuthPage/Login.js @@ -118,7 +118,7 @@ class Login extends Shadow { this.$("p").attr({ errorType: "" }); } - const res = await fetch(`${util.HOST}/login`, { + const res = await fetch(`${util.HOST}/auth/login`, { method: "POST", headers: { "Content-Type": "application/json", "X-Client": "mobile" }, body: JSON.stringify({ diff --git a/src/Home/AuthPage/Signup.js b/src/Home/AuthPage/Signup.js index f556082..31873ae 100644 --- a/src/Home/AuthPage/Signup.js +++ b/src/Home/AuthPage/Signup.js @@ -112,10 +112,12 @@ class Signup extends Shadow { } async requestSignup(data) { - const res = await fetch(`${util.HOST}/signup`, { + const networkId = this.attr("networkid"); + const res = await fetch(`${util.HOST}/auth/signup`, { method: "POST", headers: { "Content-Type": "application/json", "X-Client": "mobile" }, body: JSON.stringify({ + networkId: networkId, firstName: data.get("firstName"), lastName: data.get("lastName"), email: data.get("email"), diff --git a/src/index.js b/src/index.js index 693675e..d47d0aa 100644 --- a/src/index.js +++ b/src/index.js @@ -121,7 +121,7 @@ let Global = class { async getProfile() { try { - const res = await util.authFetch(`${util.HOST}/profile`, { + const res = await util.authFetch(`${util.HOST}/auth/profile`, { method: "GET", credentials: "include", headers: { @@ -150,7 +150,7 @@ let Global = class { async onLogout() { await util.removeAuthToken() - await fetch(`${util.HOST}/signout`, { + await fetch(`${util.HOST}/auth/signout`, { method: "GET", credentials: "include" }); diff --git a/src/public/_/code/quill.js b/src/public/_/code/quill.js index 24f5197..c1688c3 100644 --- a/src/public/_/code/quill.js +++ b/src/public/_/code/quill.js @@ -1261,7 +1261,7 @@ HTMLElement.prototype.attr = function(arg1, arg2) { this.setAttribute(arg1, arg2) return this } else if(typeof arg1 === "string") { - return this.getAttribute("") + return this.getAttribute(arg1) } else { throw new TypeError("wrong parameter for attr(): ", arg1); } diff --git a/vite.config.ts b/vite.config.ts index 1a5a653..ea3ad7e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,22 +16,6 @@ export default defineConfig({ changeOrigin: true, ws: true }, - "/login": { - target: "http://localhost:10002", - changeOrigin: true - }, - "/signup": { - target: "http://localhost:10002", - changeOrigin: true - }, - "/signout": { - target: "http://localhost:10002", - changeOrigin: true - }, - "/profile": { - target: "http://localhost:10002", - changeOrigin: true - }, "/profile/upload-image": { target: "http://localhost:10002", changeOrigin: true @@ -47,6 +31,10 @@ export default defineConfig({ "/apps": { target: "http://localhost:10002", changeOrigin: true + }, + "/auth": { + target: "http://localhost:10002", + changeOrigin: true } }, host: true,