successfully connecting to prod

This commit is contained in:
metacryst
2026-03-17 07:00:27 -05:00
parent 530ea7da89
commit d1e4814593
7 changed files with 43 additions and 31 deletions

View File

@@ -2,10 +2,6 @@
"appId": "so.forum.app",
"appName": "Forum",
"webDir": "dist",
"server": {
"url": "http://sam.local:5173",
"cleartext": true
},
"ios": {
"allowsBackForwardNavigationGestures": true
},

View File

@@ -5,6 +5,15 @@
### Build and Run (iOS App)
https://capacitorjs.com/docs/ios#adding-the-ios-platform
Add this option into the top level of capacitor.config.json if you want the ios app to call the dev server:
"server": {
"url": "http://sam.local:5173",
"cleartext": true
},
Otherwise, it will call prod.
To Install:
npm install @capacitor/ios
npx cap add ios
@@ -20,7 +29,10 @@ vite build
npx serve dist
If you need to login again:
run "localStorage.clear() in the browser dev tools console and then refresh the page.
run localStorage.clear() in the browser dev tools console and then refresh the page.
### Various Commands
npx cap config - this will list the full configuration currently being used
### Architecture

View File

@@ -1,5 +1,5 @@
const env = import.meta.env
import { Preferences } from '@capacitor/preferences';
import util from "../util.js"
class Login extends Shadow {
inputStyles(el) {
@@ -8,21 +8,21 @@ class Login extends Shadow {
.color("var(--text)")
.border("1px solid var(--accent)")
.fontSize(0.9, rem)
.backgroundColor("var(--darkaccent)")
.backgroundColor("var(--searchbackground)")
.borderRadius(12, px)
.outline("none")
.onTouch((start) => {
if(start) {
this.style.backgroundColor = "var(--accent)"
} else {
this.style.backgroundColor = "var(--darkaccent)"
this.style.backgroundColor = "var(--searchbackground)"
}
})
}
render() {
ZStack(() => {
img(window.matchMedia('(prefers-color-scheme: dark)') ? "/_/icons/columnwhite.svg" : "/_/icons/logo.svg", window.isMobile() ? "5vmax" : "3vmax")
img(window.matchMedia('(prefers-color-scheme: dark)').matches ? "/_/icons/columnwhite.svg" : "/_/icons/logo.svg", window.isMobile() ? "5vmax" : "3vmax")
.position("absolute")
.top(5, em)
.left(2, em)
@@ -43,7 +43,7 @@ class Login extends Shadow {
.margin(1, em).padding(1, em)
.fontSize(0.9, rem)
.borderRadius(12, px)
.background("var(--darkaccent)")
.background("var(--searchbackground)")
.color("var(--text)")
.border("1px solid var(--accent)")
})
@@ -53,7 +53,7 @@ class Login extends Shadow {
e.preventDefault();
const data = new FormData(e.target);
const res = await fetch(`${env.VITE_API_URL}/login`, {
const res = await fetch(`${util.HOST}/login`, {
method: "POST",
headers: { "Content-Type": "application/json", "X-Client": "mobile" },
body: JSON.stringify({

View File

@@ -1,5 +1,5 @@
import { Preferences } from '@capacitor/preferences';
const env = import.meta.env
import util from "../../../util.js"
class Connection {
connectionTries = 0;
@@ -14,8 +14,8 @@ class Connection {
const { value: token } = await Preferences.get({ key: 'auth_token' });
return new Promise((resolve, reject) => {
let url = ""
if(env.VITE_API_URL) {
url = "wss://" + env.VITE_API_URL.replace(/^https?:\/\//, '') + "/ws" + `?token=${token}`;
if(util.HOST) {
url = "wss://" + util.HOST.replace(/^https?:\/\//, '') + "/ws" + `?token=${token}`;
} else {
url = "ws://" + window.location.host + "/ws"
}

View File

@@ -1,7 +1,9 @@
import util from "../util.js"
class TopBar extends Shadow {
render() {
HStack(() => {
img(`/db/images/${global.currentNetwork.logo}`, "2.5em", "2.5em")
img(`${util.HOST}/db/images/${global.currentNetwork.logo}`, "2.5em", "2.5em")
.borderRadius("50", pct)
.objectFit("cover")
.padding(0.3, em)

View File

@@ -4,8 +4,6 @@ import "./Home/Login.js"
import "./Home/ConnectionError.js"
import util from "./util.js"
const env = import.meta.env
let Global = class {
Socket = new Socket()
profile = null
@@ -34,7 +32,7 @@ let Global = class {
async fetchAppData() {
let personalSpace = this.currentNetwork === this.profile
if (personalSpace) { return {} }
let appData = await fetch(`${env.VITE_API_URL}/api/${personalSpace ? "my" : "org"}data/` + this.currentNetwork.id, {method: "GET"})
let appData = await fetch(`${util.HOST}/api/${personalSpace ? "my" : "org"}data/` + this.currentNetwork.id, {method: "GET"})
let json = await appData.json()
return json
}
@@ -119,7 +117,7 @@ let Global = class {
async getProfile() {
try {
const res = await util.authFetch(`${env.VITE_API_URL}/profile`, {
const res = await util.authFetch(`${util.HOST}/profile`, {
method: "GET",
credentials: "include",
headers: {

View File

@@ -1,6 +1,10 @@
import { Preferences } from '@capacitor/preferences';
const env = import.meta.env
export default class util {
static HOST = env.VITE_API_URL
static async authFetch(url, options = {}) {
const { value: token } = await Preferences.get({ key: 'auth_token' });