Embded frontend inside go binary
This will simplify the self hosting of the platform. Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -11,7 +11,7 @@ const fetchRelay: FetchFunction = async (
|
||||
request,
|
||||
variables,
|
||||
_,
|
||||
uploadables,
|
||||
uploadables
|
||||
) => {
|
||||
const requestInit: RequestInit = {
|
||||
method: "POST",
|
||||
@@ -27,7 +27,7 @@ const fetchRelay: FetchFunction = async (
|
||||
operationName: request.name,
|
||||
query: request.text,
|
||||
variables: variables,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
const uploadableMap: {
|
||||
@@ -59,7 +59,10 @@ const fetchRelay: FetchFunction = async (
|
||||
});
|
||||
}
|
||||
|
||||
const response = await fetch(buildEndpoint("/console/v1/query"), requestInit);
|
||||
const response = await fetch(
|
||||
buildEndpoint("/api/console/v1/query"),
|
||||
requestInit
|
||||
);
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
@@ -68,8 +71,8 @@ const fetchRelay: FetchFunction = async (
|
||||
`Error fetching GraphQL query '${
|
||||
request.name
|
||||
}' with variables '${JSON.stringify(variables)}': ${JSON.stringify(
|
||||
json.errors,
|
||||
)}`,
|
||||
json.errors
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const checkAuth = async (): Promise<boolean> => {
|
||||
try {
|
||||
// Make a request to an endpoint that requires authentication
|
||||
const response = await fetch(buildEndpoint("/console/v1/query"), {
|
||||
const response = await fetch(buildEndpoint("/api/console/v1/query"), {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function LoginPage() {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const response = await fetch(buildEndpoint("/console/v1/auth/login"), {
|
||||
const response = await fetch(buildEndpoint("/api/console/v1/auth/login"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function RegisterPage() {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const response = await fetch(buildEndpoint("/console/v1/auth/register"), {
|
||||
const response = await fetch(buildEndpoint("/api/console/v1/auth/register"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
export function buildEndpoint(path: string): string {
|
||||
const host = process.env.API_SERVER_HOST!;
|
||||
|
||||
if (!host) {
|
||||
return path;
|
||||
}
|
||||
|
||||
const formattedHost =
|
||||
host.startsWith("http://") || host.startsWith("https://")
|
||||
? host
|
||||
: `https://${host}`;
|
||||
|
||||
const url = new URL(formattedHost);
|
||||
|
||||
if (path) {
|
||||
|
||||
Reference in New Issue
Block a user