Skip to content

Instantly share code, notes, and snippets.

@runeh
Created June 25, 2018 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runeh/45823ddf2a22067820b42795500e756e to your computer and use it in GitHub Desktop.
Save runeh/45823ddf2a22067820b42795500e756e to your computer and use it in GitHub Desktop.
const client = sanityClient({
projectId: 'p354jyup',
dataset: 'main',
useCdn: true,
});
// needs polyfill
const origin = window.location.origin
client.clientConfig.cdnUrl = `${origin}/sanity`;
client.clientConfig.url = `${origin}/sanity`;
app.use(
'/sanity',
proxy('https://p354jyup.apicdn.sanity.io/', {
https: true,
proxyReqPathResolver: function(req: express.Request) {
const parts = parseUrl(req.url);
return `/v1${parts.pathname}?${parts.search || ''}`;
},
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment