Factor out API URL to env
This commit is contained in:
3
frontend/src/env.ts
Normal file
3
frontend/src/env.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const API_URL = import.meta.env.API_URL;
|
||||
|
||||
export { API_URL };
|
@@ -1,15 +1,16 @@
|
||||
---
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
import type { APIResponse, Player, Note } from "../types";
|
||||
import { API_URL } from "../env";
|
||||
|
||||
const res = await fetch("https://stinky-backend.site.quack-lab.dev/player");
|
||||
const res = await fetch(`${API_URL}/player`);
|
||||
const data: APIResponse<Player[]> = await res.json();
|
||||
|
||||
const request = { success: true, message: "" };
|
||||
if (Astro.request.method === "POST") {
|
||||
try {
|
||||
const body = await Astro.request.text();
|
||||
const res = await fetch("https://stinky-backend.site.quack-lab.dev/note/new", {
|
||||
const res = await fetch(`${API_URL}/note/new`, {
|
||||
method: "POST",
|
||||
body,
|
||||
});
|
||||
|
@@ -1,6 +1,7 @@
|
||||
---
|
||||
const { name } = Astro.params;
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import { API_URL } from "../../env";
|
||||
---
|
||||
|
||||
<Layout title={name || "Player"}>
|
||||
|
Reference in New Issue
Block a user