mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 00:40:58 +01:00
fix: use hostname for suspense query url (#2187)
This commit is contained in:
@@ -5,7 +5,7 @@ import { createTRPCReact } from "@trpc/react-query";
|
||||
import SuperJSON from "superjson";
|
||||
|
||||
import type { AppRouter } from ".";
|
||||
import { createHeadersCallbackForSource } from "./shared";
|
||||
import { createHeadersCallbackForSource, getTrpcUrl } from "./shared";
|
||||
|
||||
export const clientApi = createTRPCReact<AppRouter>();
|
||||
export const fetchApi = createTRPCClient<AppRouter>({
|
||||
@@ -17,16 +17,3 @@ export const fetchApi = createTRPCClient<AppRouter>({
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
function getBaseUrl() {
|
||||
if (typeof window !== "undefined") return window.location.origin;
|
||||
return `http://localhost:${process.env.PORT ?? 3000}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the full url for the trpc api endpoint
|
||||
* @returns
|
||||
*/
|
||||
export function getTrpcUrl() {
|
||||
return `${getBaseUrl()}/api/trpc`;
|
||||
}
|
||||
|
||||
@@ -36,3 +36,18 @@ async function importCookiesAsync() {
|
||||
.map(({ name, value }) => `${name}=${value}`)
|
||||
.join(";");
|
||||
}
|
||||
|
||||
function getBaseUrl() {
|
||||
if (typeof window !== "undefined") return window.location.origin;
|
||||
return `http://${process.env.HOSTNAME ?? "localhost"}:3000`;
|
||||
}
|
||||
|
||||
export const trpcPath = "/api/trpc";
|
||||
|
||||
/**
|
||||
* Creates the full url for the trpc api endpoint
|
||||
* @returns
|
||||
*/
|
||||
export function getTrpcUrl() {
|
||||
return `${getBaseUrl()}${trpcPath}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user