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} */
const nextConfig = {
images: {
domains: ["localhost", "tube.stiforr.tech"],
},
experimental: {
runtime: "nodejs",
},

View File

@ -43,7 +43,7 @@ export const VideoList = ({ videos }: { videos: Videos }) => {
light="false"
playing // TODO: Not currently working
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">
<NextImage
@ -171,7 +171,7 @@ export const VideoList = ({ videos }: { videos: Videos }) => {
<div className="video-thumb-wrap list">
<div className="video-thumb">
<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"
width={250}
height={141}

View File

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