diff --git a/packages/dashboard/Dockerfile b/packages/dashboard/Dockerfile index 8eaa2590..2efa163f 100644 --- a/packages/dashboard/Dockerfile +++ b/packages/dashboard/Dockerfile @@ -13,4 +13,4 @@ COPY styles ./styles COPY postcss.config.js . COPY tailwind.config.js . -CMD ["sh", "-c", "yarn build && yarn start"] +CMD ["sh", "-c", "env | grep NEXT_PUBLIC_ > .env.local && yarn build && yarn start"] diff --git a/packages/dashboard/src/pages/downloads.js b/packages/dashboard/src/pages/downloads.js index 763c6726..0c559063 100644 --- a/packages/dashboard/src/pages/downloads.js +++ b/packages/dashboard/src/pages/downloads.js @@ -7,7 +7,7 @@ import Table from "../components/Table"; import authServerSideProps from "../services/authServerSideProps"; import { SkynetClient } from "skynet-js"; -const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); +const skynetClient = new SkynetClient(process.env.NEXT_PUBLIC_SKYNET_PORTAL_API); const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : ""; const fetcher = (url) => fetch(url).then((r) => r.json()); const getSkylinkLink = ({ skylink }) => skynetClient.getSkylinkUrl(skylink); diff --git a/packages/dashboard/src/pages/index.js b/packages/dashboard/src/pages/index.js index 34c857d4..d4dcf77e 100644 --- a/packages/dashboard/src/pages/index.js +++ b/packages/dashboard/src/pages/index.js @@ -9,7 +9,7 @@ import { SkynetClient } from "skynet-js"; dayjs.extend(relativeTime); -const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); +const skynetClient = new SkynetClient(process.env.NEXT_PUBLIC_SKYNET_PORTAL_API); const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : ""; const fetcher = (url) => fetch(url).then((r) => r.json()); diff --git a/packages/dashboard/src/pages/uploads.js b/packages/dashboard/src/pages/uploads.js index ee718b43..2d6ba195 100644 --- a/packages/dashboard/src/pages/uploads.js +++ b/packages/dashboard/src/pages/uploads.js @@ -7,25 +7,22 @@ import Table from "../components/Table"; import authServerSideProps from "../services/authServerSideProps"; import { SkynetClient } from "skynet-js"; +const skynetClient = new SkynetClient(process.env.NEXT_PUBLIC_SKYNET_PORTAL_API); const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : ""; const fetcher = (url) => fetch(url).then((r) => r.json()); +const getSkylinkLink = ({ skylink }) => skynetClient.getSkylinkUrl(skylink); +const getRelativeDate = ({ uploadedOn }) => dayjs(uploadedOn).format("YYYY-MM-DD HH:mm:ss"); +const headers = [ + { key: "name", name: "Name", nowrap: false, href: getSkylinkLink }, + { key: "skylink", name: "Skylink" }, + { key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) }, + { key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate }, +]; +const actions = []; -export const getServerSideProps = authServerSideProps(() => { - const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); - const getSkylinkLink = ({ skylink }) => skynetClient.getSkylinkUrl(skylink); - const getRelativeDate = ({ uploadedOn }) => dayjs(uploadedOn).format("YYYY-MM-DD HH:mm:ss"); - const headers = [ - { key: "name", name: "Name", nowrap: false, href: getSkylinkLink }, - { key: "skylink", name: "Skylink" }, - { key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) }, - { key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate }, - ]; - const actions = []; +export const getServerSideProps = authServerSideProps(); - return { props: { headers, actions } }; -}); - -export default function Uploads({ headers, actions }) { +export default function Uploads() { const [offset, setOffset] = useState(0); const { data, error } = useSWR(`${apiPrefix}/user/uploads?pageSize=10&offset=${offset}`, fetcher);