fix(mobile): update public menu URL format to https://menul.io/menu/:slug
This commit is contained in:
@@ -2,6 +2,15 @@ import { supabase } from "./supabase";
|
||||
|
||||
const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "http://localhost:3001";
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
|
||||
constructor(status: number, message: string) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
async function authHeaders(): Promise<Record<string, string>> {
|
||||
const { data } = await supabase.auth.getSession();
|
||||
const token = data.session?.access_token;
|
||||
@@ -17,7 +26,7 @@ async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({ message: res.statusText }));
|
||||
throw new Error(body.message ?? `Request failed: ${res.status}`);
|
||||
throw new ApiError(res.status, body.message ?? `Request failed: ${res.status}`);
|
||||
}
|
||||
|
||||
if (res.status === 204) return undefined as T;
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
const WEB_BASE_URL = process.env.EXPO_PUBLIC_WEB_URL || "http://localhost:3000";
|
||||
const WEB_BASE_URL = (process.env.EXPO_PUBLIC_WEB_URL || "https://menul.io").replace(/\/+$/, "");
|
||||
|
||||
export function getPublicMenuUrl(slug: string): string {
|
||||
if (WEB_BASE_URL.includes("menul.io")) {
|
||||
return `https://${slug}.menul.io`;
|
||||
}
|
||||
return `${WEB_BASE_URL}/menu/${slug}`;
|
||||
}
|
||||
|
||||
export function getPublicMenuDisplayUrl(slug: string): string {
|
||||
if (WEB_BASE_URL.includes("menul.io")) {
|
||||
return `${slug}.menul.io`;
|
||||
}
|
||||
return `${WEB_BASE_URL.replace(/^https?:\/\//, "")}/menu/${slug}`;
|
||||
const displayBase = WEB_BASE_URL.replace(/^https?:\/\//, "");
|
||||
return `${displayBase}/menu/${slug}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user