mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix: update API fetch calls to use dynamic apiUrl
This commit is contained in:
@@ -3,10 +3,12 @@ import type { Paste } from '$lib/types/paste';
|
|||||||
import { getServerToken } from '$lib/utils/auth';
|
import { getServerToken } from '$lib/utils/auth';
|
||||||
import { env } from '$env/dynamic/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
|
const apiUrl = process.env.VITE_API_URL || 'http://localhost:5050';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch, url, cookies }) => {
|
export const load: PageServerLoad = async ({ params, fetch, url, cookies }) => {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
|
||||||
const paste = await fetch(`/api/paste/${id}`);
|
const paste = await fetch(`${apiUrl}/api/paste/${id}`);
|
||||||
if (paste.status === 404) {
|
if (paste.status === 404) {
|
||||||
return {
|
return {
|
||||||
status: 404,
|
status: 404,
|
||||||
@@ -17,7 +19,7 @@ export const load: PageServerLoad = async ({ params, fetch, url, cookies }) => {
|
|||||||
const token = getServerToken(cookies);
|
const token = getServerToken(cookies);
|
||||||
const apiKey = env.VIEW_INTERNAL_API_KEY ?? env.View_HMAC_Internal_API_Key ?? '';
|
const apiKey = env.VIEW_INTERNAL_API_KEY ?? env.View_HMAC_Internal_API_Key ?? '';
|
||||||
|
|
||||||
const viewed = await fetch(`/api/paste/${id}/view`, {
|
const viewed = await fetch(`${apiUrl}/api/paste/${id}/view`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Internal-API-Key': apiKey,
|
'X-Internal-API-Key': apiKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user