diff --git a/web/pages/api/collection/[id].js b/web/pages/api/collection/[id].js index 4c04d9941bcfc44173b04f46a2a9b267e7712dae..a01dfaf3c69058d0066b0a4ded103468155f5abd 100644 --- a/web/pages/api/collection/[id].js +++ b/web/pages/api/collection/[id].js @@ -1,6 +1,7 @@ import {sanityClient, previewClient} from '../../../lib/sanity.server' const getClient = (preview) => (preview ? previewClient : sanityClient) +const domain = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "http://localhost:3000" /* Construct a IIIF Presentation v3 collection json */ @@ -26,11 +27,11 @@ export default async function handler(req, res) { async function getObject(preview = false) { const results = await getClient(id, preview).fetch(` *[_id == $id][0] { - "id": "http://localhost:3000/api/collection/" + _id, + "id": "${domain}/api/collection/" + _id, "type": "Collection", label, "items":*[_type == "HumanMadeObject" && ^._id in hasCurrentOwner[]._ref] { - "id": coalesce(subjectOfManifest, "http://localhost:3000/api/manifest/" + _id), + "id": coalesce(subjectOfManifest, "${domain}/api/manifest/" + _id), "type": "Manifest", label } diff --git a/web/pages/api/collection/index.js b/web/pages/api/collection/index.js index c024e227ef9c7cd545ce5e777e0fd2c144daf743..566c8b6a3894e6fa1fa2bc196a4bf424888d4e53 100644 --- a/web/pages/api/collection/index.js +++ b/web/pages/api/collection/index.js @@ -1,6 +1,7 @@ import {sanityClient, previewClient} from '../../../lib/sanity.server' const getClient = (preview) => (preview ? previewClient : sanityClient) +const domain = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "http://localhost:3000" /* Construct a IIIF Presentation v3 collection json */ @@ -40,7 +41,7 @@ export default async function handler(req, res) { async function getObject(preview = false) { const results = await getClient(preview).fetch(` *[_type == "Group" && count(*[_type == "HumanMadeObject" && ^._id in hasCurrentOwner[]._ref]) > 0] { - "id": "http://localhost:3000/api/collection/" + _id, + "id": "${domain}/api/collection/" + _id, "type": "Collection", label, }