mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-12 21:30:27 +05:30
feat: allow setting API, proxy, and frontend URLs at build time (#3284)
This commit is contained in:
parent
f033ee7af7
commit
84b2637d7d
3
.env
Normal file
3
.env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
VITE_PIPED_API=https://pipedapi.kavin.rocks
|
||||||
|
VITE_PIPED_PROXY=https://pipedproxy.kavin.rocks
|
||||||
|
VITE_PIPED_INSTANCES=https://piped-instances.kavin.rocks/
|
@ -1,6 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html style="background: #0f0f0f" lang="en" >
|
<html style="background: #0f0f0f" lang="en" >
|
||||||
<head>
|
<head>
|
||||||
|
<base href="%BASE_URL%"/>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
|
@ -51,7 +51,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
//TODO: Add Server Side check
|
//TODO: Add Server Side check
|
||||||
if (this.getAuthToken()) {
|
if (this.getAuthToken()) {
|
||||||
this.$router.push("/");
|
this.$router.push(import.meta.env.BASE_URL);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
@ -69,7 +69,7 @@ export default {
|
|||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
if (resp.token) {
|
if (resp.token) {
|
||||||
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
|
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
|
||||||
window.location = "/"; // done to bypass cache
|
window.location = import.meta.env.BASE_URL; // done to bypass cache
|
||||||
} else alert(resp.error);
|
} else alert(resp.error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -131,7 +131,7 @@ export default {
|
|||||||
searchText: "",
|
searchText: "",
|
||||||
suggestionsVisible: false,
|
suggestionsVisible: false,
|
||||||
showTopNav: false,
|
showTopNav: false,
|
||||||
homePagePath: "/",
|
homePagePath: import.meta.env.BASE_URL,
|
||||||
registrationDisabled: false,
|
registrationDisabled: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
<script setup>
|
||||||
|
const homeUrl = import.meta.env.BASE_URL;
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-[88vh] flex flex-col items-center justify-center">
|
<div class="min-h-[88vh] flex flex-col items-center justify-center">
|
||||||
<h1 class="font-bold !text-9xl">404</h1>
|
<h1 class="font-bold !text-9xl">404</h1>
|
||||||
<h2 v-t="'info.page_not_found'" class="!text-2xl" />
|
<h2 v-t="'info.page_not_found'" class="!text-2xl" />
|
||||||
<a v-t="'actions.back_to_home'" class="btn mt-16" href="/" />
|
<a v-t="'actions.back_to_home'" class="btn mt-16" :href="homeUrl" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -504,7 +504,7 @@ export default {
|
|||||||
async mounted() {
|
async mounted() {
|
||||||
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
||||||
|
|
||||||
this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => {
|
this.fetchJson(import.meta.env.VITE_PIPED_INSTANCES).then(resp => {
|
||||||
this.instances = resp;
|
this.instances = resp;
|
||||||
if (!this.instances.some(instance => instance.api_url == this.apiUrl()))
|
if (!this.instances.some(instance => instance.api_url == this.apiUrl()))
|
||||||
this.instances.push({
|
this.instances.push({
|
||||||
@ -517,7 +517,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.testLocalStorage) {
|
if (this.testLocalStorage) {
|
||||||
this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
this.selectedInstance = this.getPreferenceString("instance", import.meta.env.VITE_PIPED_API);
|
||||||
this.authInstance = this.getPreferenceBoolean("authInstance", false);
|
this.authInstance = this.getPreferenceBoolean("authInstance", false);
|
||||||
this.selectedAuthInstance = this.getPreferenceString("auth_instance_url", this.selectedInstance);
|
this.selectedAuthInstance = this.getPreferenceString("auth_instance_url", this.selectedInstance);
|
||||||
|
|
||||||
@ -655,14 +655,14 @@ export default {
|
|||||||
// reset the auth token
|
// reset the auth token
|
||||||
localStorage.removeItem("authToken" + this.hashCode(this.authApiUrl()));
|
localStorage.removeItem("authToken" + this.hashCode(this.authApiUrl()));
|
||||||
// redirect to trending page
|
// redirect to trending page
|
||||||
window.location = "/";
|
window.location = import.meta.env.BASE_URL;
|
||||||
},
|
},
|
||||||
resetPreferences() {
|
resetPreferences() {
|
||||||
this.showConfirmResetPrefsDialog = false;
|
this.showConfirmResetPrefsDialog = false;
|
||||||
// clear the local storage
|
// clear the local storage
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
// redirect to the home page
|
// redirect to the home page
|
||||||
window.location = "/";
|
window.location = import.meta.env.BASE_URL;
|
||||||
},
|
},
|
||||||
async invalidateSession() {
|
async invalidateSession() {
|
||||||
this.fetchJson(this.authApiUrl() + "/logout", null, {
|
this.fetchJson(this.authApiUrl() + "/logout", null, {
|
||||||
|
@ -83,7 +83,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
//TODO: Add Server Side check
|
//TODO: Add Server Side check
|
||||||
if (this.getAuthToken()) {
|
if (this.getAuthToken()) {
|
||||||
this.$router.push("/");
|
this.$router.push(import.meta.env.BASE_URL);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
@ -109,7 +109,7 @@ export default {
|
|||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
if (resp.token) {
|
if (resp.token) {
|
||||||
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
|
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
|
||||||
window.location = "/"; // done to bypass cache
|
window.location = import.meta.env.BASE_URL; // done to bypass cache
|
||||||
} else alert(resp.error);
|
} else alert(resp.error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,12 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$route.path == "/" && this.getPreferenceString("homepage", "trending") == "feed") return;
|
if (
|
||||||
|
this.$route.path == import.meta.env.BASE_URL &&
|
||||||
|
this.getPreferenceString("homepage", "trending") == "feed"
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let region = this.getPreferenceString("region", "US");
|
let region = this.getPreferenceString("region", "US");
|
||||||
|
|
||||||
this.fetchTrending(region).then(videos => {
|
this.fetchTrending(region).then(videos => {
|
||||||
@ -35,7 +40,7 @@ export default {
|
|||||||
activated() {
|
activated() {
|
||||||
document.title = this.$t("titles.trending") + " - Piped";
|
document.title = this.$t("titles.trending") + " - Piped";
|
||||||
if (this.videos.length > 0) this.updateWatched(this.videos);
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
||||||
if (this.$route.path == "/") {
|
if (this.$route.path == import.meta.env.BASE_URL) {
|
||||||
let homepage = this.getHomePage(this);
|
let homepage = this.getHomePage(this);
|
||||||
if (homepage !== undefined) this.$router.push(homepage);
|
if (homepage !== undefined) this.$router.push(homepage);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ const mixin = {
|
|||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
apiUrl() {
|
apiUrl() {
|
||||||
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
return this.getPreferenceString("instance", import.meta.env.VITE_PIPED_API);
|
||||||
},
|
},
|
||||||
authApiUrl() {
|
authApiUrl() {
|
||||||
if (this.getPreferenceBoolean("authInstance", false)) {
|
if (this.getPreferenceBoolean("authInstance", false)) {
|
||||||
@ -347,7 +347,7 @@ const mixin = {
|
|||||||
id: playlistId,
|
id: playlistId,
|
||||||
name: name,
|
name: name,
|
||||||
description: "",
|
description: "",
|
||||||
thumbnail: "https://pipedproxy.kavin.rocks/?host=i.ytimg.com",
|
thumbnail: import.meta.env.VITE_PIPED_PROXY + "/?host=i.ytimg.com",
|
||||||
videoIds: "[]", // empty list
|
videoIds: "[]", // empty list
|
||||||
});
|
});
|
||||||
return { playlistId: playlistId };
|
return { playlistId: playlistId };
|
||||||
@ -471,7 +471,7 @@ const mixin = {
|
|||||||
const videoIds = JSON.parse(playlist.videoIds);
|
const videoIds = JSON.parse(playlist.videoIds);
|
||||||
videoIds.splice(index, 1);
|
videoIds.splice(index, 1);
|
||||||
playlist.videoIds = JSON.stringify(videoIds);
|
playlist.videoIds = JSON.stringify(videoIds);
|
||||||
if (videoIds.length == 0) playlist.thumbnail = "https://pipedproxy.kavin.rocks/?host=i.ytimg.com";
|
if (videoIds.length == 0) playlist.thumbnail = import.meta.env.VITE_PIPED_PROXY + "/?host=i.ytimg.com";
|
||||||
this.createOrUpdateLocalPlaylist(playlist);
|
this.createOrUpdateLocalPlaylist(playlist);
|
||||||
return { message: "ok" };
|
return { message: "ok" };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user