Update to frontend, allow selecting the server you use in Dev (#422)

This commit is contained in:
JackDawson94
2022-06-30 14:19:32 +02:00
committed by GitHub
parent 16147dbaae
commit 84774d5826
2 changed files with 11 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
VITE_APIKEY=<stash-box API key>
#VITE_SERVER_PORT=9998
#VITE_SERVER_URL=https://stash server.example
#VITE_SERVER_PORT=443
#PORT=3001

View File

@@ -20,13 +20,19 @@ const typePolicies: TypePolicies = {
const isDevEnvironment = () => import.meta.env.DEV;
export const getCredentialsSetting = () =>
isDevEnvironment() ? "include" : "same-origin";
isDevEnvironment() && !import.meta.env.VITE_SERVER_URL
? "include"
: "same-origin";
export const getPlatformURL = () => {
const platformUrl = new URL(window.location.origin);
let platformUrl = new URL(window.location.origin);
if (isDevEnvironment())
if (isDevEnvironment()) {
platformUrl = new URL(
import.meta.env.VITE_SERVER_URL ?? window.location.origin
);
platformUrl.port = import.meta.env.VITE_SERVER_PORT ?? "9998";
}
return platformUrl;
};