chore: use env var for api url

This commit is contained in:
Sean Norwood 2022-04-06 18:31:05 +00:00
parent d86cf81719
commit 42ff29c13d
3 changed files with 16 additions and 10 deletions

View File

@ -1,5 +1,8 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
images: {
domains: ["localhost", "tube.stiforr.tech"],
},
experimental: { experimental: {
runtime: "nodejs", runtime: "nodejs",
}, },

View File

@ -43,7 +43,7 @@ export const VideoList = ({ videos }: { videos: Videos }) => {
light="false" light="false"
playing // TODO: Not currently working playing // TODO: Not currently working
playsinline playsinline
url={`http://localhost:8000/media/${selectedVideoUrl.media_url}`} url={`${process.env.NEXT_PUBLIC_TUBEARCHIVIST_URL}/media/${selectedVideoUrl.media_url}`}
/> />
<div className="player-title boxed-content"> <div className="player-title boxed-content">
<NextImage <NextImage
@ -171,7 +171,7 @@ export const VideoList = ({ videos }: { videos: Videos }) => {
<div className="video-thumb-wrap list"> <div className="video-thumb-wrap list">
<div className="video-thumb"> <div className="video-thumb">
<NextImage <NextImage
src={`http://localhost:8000/cache/${video.vid_thumb_url}`} src={`${process.env.NEXT_PUBLIC_TUBEARCHIVIST_URL}/cache/${video.vid_thumb_url}`}
alt="video-thumb" alt="video-thumb"
width={250} width={250}
height={141} height={141}

View File

@ -34,14 +34,17 @@ const Home: NextPage<{ videos: Videos }> = ({ videos }) => {
export default Home; export default Home;
export const getServerSideProps: GetServerSideProps = async (ctx) => { export const getServerSideProps: GetServerSideProps = async (ctx) => {
const response = await fetch("http://localhost:8000/api/video/", { const response = await fetch(
headers: { `${process.env.NEXT_PUBLIC_TUBEARCHIVIST_URL}/api/video/`,
Accept: "application/json", {
"Content-Type": "application/json", headers: {
Authorization: `Token b4d4330462c7fc16c51873e45579b29a1a12fc90`, Accept: "application/json",
mode: "no-cors", "Content-Type": "application/json",
}, Authorization: `Token b4d4330462c7fc16c51873e45579b29a1a12fc90`,
}); mode: "no-cors",
},
}
);
const videos = await response.json(); const videos = await response.json();
return { props: { videos } }; return { props: { videos } };