automatically set the base url

This commit is contained in:
Milo Schwartz 2024-10-06 14:09:26 -04:00
parent 29777da430
commit 0838679120
No known key found for this signature in database
4 changed files with 40 additions and 38 deletions

View file

@ -44,7 +44,7 @@ const environmentSchema = z.object({
EMAIL_SMTP_USER: z.string().optional(),
EMAIL_SMTP_PASS: z.string().optional(),
EMAIL_NOREPLY: z.string().email().optional(),
SITE_DOMAIN: z
BASE_URL: z
.string()
.optional()
.transform((val) => {
@ -73,7 +73,7 @@ const environment = {
EMAIL_SMTP_USER: process.env.EMAIL_SMTP_USER as string,
EMAIL_SMTP_PASS: process.env.EMAIL_SMTP_PASS as string,
EMAIL_NOREPLY: process.env.EMAIL_NOREPLY as string,
SITE_DOMAIN: process.env.NEXT_PUBLIC_SITE_DOMAIN as string,
BASE_URL: process.env.BASE_URL as string,
};
const parsedConfig = environmentSchema.safeParse(environment);

View file

@ -1,7 +1,9 @@
import axios from "axios";
const baseURL = `${window.location.protocol}//${window.location.host}/api/v1`;
export const api = axios.create({
baseURL: `http://${process.env.NEXT_PUBLIC_SITE_DOMAIN || "localhost:3000"}/api/v1`,
baseURL,
timeout: 10000,
headers: {
"Content-Type": "application/json",

View file

@ -24,8 +24,8 @@ import {
} from "@/components/ui/card";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
import api from "@app/api";
import { LoginBody, LoginResponse } from "@server/routers/auth";
import { LoginResponse } from "@server/routers/auth";
import { api } from "@app/api";
const formSchema = z.object({
email: z.string().email({ message: "Invalid email address" }),
@ -48,7 +48,7 @@ export default function LoginForm() {
async function onSubmit(values: z.infer<typeof formSchema>) {
const { email, password } = values;
const res = await api
.post<LoginBody, LoginResponse>("/auth/login", {
.post<LoginResponse>("/auth/login", {
email,
password,
})

View file

@ -3,47 +3,47 @@
@tailwind utilities;
@layer base {
:root {
--background: 31 100% 100%;
--foreground: 31 5% 10%;
--card: 31 50% 100%;
--card-foreground: 31 5% 15%;
--popover: 31 100% 100%;
--popover-foreground: 31 100% 10%;
--primary: 31 11% 28%;
--background: 37 100% 100%;
--foreground: 37 5% 10%;
--card: 37 50% 100%;
--card-foreground: 37 5% 15%;
--popover: 37 100% 100%;
--popover-foreground: 37 100% 10%;
--primary: 37 8% 51%;
--primary-foreground: 0 0% 100%;
--secondary: 31 30% 90%;
--secondary: 37 30% 90%;
--secondary-foreground: 0 0% 0%;
--muted: -7 30% 95%;
--muted-foreground: 31 5% 40%;
--accent: -7 30% 90%;
--accent-foreground: 31 5% 15%;
--muted: -1 30% 95%;
--muted-foreground: 37 5% 40%;
--accent: -1 30% 90%;
--accent-foreground: 37 5% 15%;
--destructive: 0 100% 50%;
--destructive-foreground: 31 5% 100%;
--border: 31 30% 82%;
--input: 31 30% 50%;
--ring: 31 11% 28%;
--destructive-foreground: 37 5% 100%;
--border: 37 30% 82%;
--input: 37 30% 50%;
--ring: 37 8% 51%;
--radius: 0rem;
}
.dark {
--background: 31 50% 10%;
--foreground: 31 5% 100%;
--card: 31 50% 10%;
--card-foreground: 31 5% 100%;
--popover: 31 50% 5%;
--popover-foreground: 31 5% 100%;
--primary: 31 11% 28%;
--background: 37 50% 10%;
--foreground: 37 5% 100%;
--card: 37 50% 10%;
--card-foreground: 37 5% 100%;
--popover: 37 50% 5%;
--popover-foreground: 37 5% 100%;
--primary: 37 8% 51%;
--primary-foreground: 0 0% 100%;
--secondary: 31 30% 20%;
--secondary: 37 30% 20%;
--secondary-foreground: 0 0% 100%;
--muted: -7 30% 25%;
--muted-foreground: 31 5% 65%;
--accent: -7 30% 25%;
--accent-foreground: 31 5% 95%;
--muted: -1 30% 25%;
--muted-foreground: 37 5% 65%;
--accent: -1 30% 25%;
--accent-foreground: 37 5% 95%;
--destructive: 0 100% 50%;
--destructive-foreground: 31 5% 100%;
--border: 31 30% 50%;
--input: 31 30% 50%;
--ring: 31 11% 28%;
--destructive-foreground: 37 5% 100%;
--border: 37 30% 50%;
--input: 37 30% 50%;
--ring: 37 8% 51%;
--radius: 0rem;
}
}