diff --git a/examples/ckan/next.config.js b/examples/ckan/next.config.js index a843cbee..aea63059 100644 --- a/examples/ckan/next.config.js +++ b/examples/ckan/next.config.js @@ -1,6 +1,11 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, -} + publicRuntimeConfig: { + DMS: process.env.DMS + ? process.env.DMS.replace(/\/?$/, '') + : 'https://demo.dev.datopian.com/', + }, +}; -module.exports = nextConfig +module.exports = nextConfig; diff --git a/examples/ckan/pages/[org]/[dataset]/index.tsx b/examples/ckan/pages/[org]/[dataset]/index.tsx index 4b56419d..f95eab96 100644 --- a/examples/ckan/pages/[org]/[dataset]/index.tsx +++ b/examples/ckan/pages/[org]/[dataset]/index.tsx @@ -6,6 +6,9 @@ import { PaperClipIcon, } from "@heroicons/react/20/solid"; import Link from "next/link"; +import getConfig from "next/config"; + +const backend_url = getConfig().publicRuntimeConfig.DMS export const getServerSideProps = async (context: any) => { try { @@ -15,7 +18,7 @@ export const getServerSideProps = async (context: any) => { notFound: true, }; } - const ckan = new CKAN("https://demo.dev.datopian.com"); + const ckan = new CKAN(backend_url); const dataset = await ckan.getDatasetDetails(datasetName as string); if (!dataset) { return { diff --git a/examples/ckan/pages/index.tsx b/examples/ckan/pages/index.tsx index e771cbff..92f2c344 100644 --- a/examples/ckan/pages/index.tsx +++ b/examples/ckan/pages/index.tsx @@ -6,10 +6,13 @@ import { Organization, Group, } from "@portaljs/ckan"; +import getConfig from "next/config"; import { useState } from "react"; +const backend_url = getConfig().publicRuntimeConfig.DMS + export async function getServerSideProps() { - const ckan = new CKAN("https://demo.dev.datopian.com"); + const ckan = new CKAN(backend_url); const groups = await ckan.getGroupsWithDetails(); const orgs = await ckan.getOrgsWithDetails(); return { @@ -27,7 +30,7 @@ export default function Home({ orgs: Organization[]; groups: Group[]; }) { - const ckan = new CKAN("https://demo.dev.datopian.com"); + const ckan = new CKAN(backend_url); const [options, setOptions] = useState({ offset: 0, limit: 5,