Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Embedding Sanity Studio on a subroute of a website and injecting project IDs at runtime

15 replies
Last updated: Sep 23, 2021
is there a defined method to embedded sanity studio on a subroute of another website, i.e. react application at
/admin
I’ve been struggling to to this well. and we don’t want to organise separate hosting, at a
admin.*
domain.
Sep 20, 2021, 2:06 AM
tried that but after loggin in to sanity with a single signon, it sounds back to the /{basepath}/desk which 404s, but if I manually route back to the base path then i’m logged in.would there be a recomendation to handle routing dirrectly to subroutes within sanity like the above?
Sep 21, 2021, 10:47 PM
What does your
sanity.json
look like? It sounds like something might not be configured correctly. Here's an example of one of the starters that uses this method.
Sep 21, 2021, 10:56 PM
i’m going to split it out and do the hosting separately for simplisity and speed up build times. but… with your example sanity.json you linked too, I learnt about that I can inject the projectId with a environment varable which is great. as will we hope to have the same codebase, but a sanity instance per client. 🙂
Sep 22, 2021, 10:19 PM
is there a way to inject those projectID’s at runtime rather than build time, so that we can have the same built assets?? so that we only need the one build pipeline.
Sep 22, 2021, 10:20 PM
?
Sep 22, 2021, 10:20 PM
is there a way to inject those projectID’s at runtime rather than build time, so that we can have the same built assets?? so that we only need the one build pipeline.
Sep 22, 2021, 10:20 PM
thank you for your help btw, really appreciate it
Sep 22, 2021, 10:20 PM
Very happy to help! And, to be honest, I can't remember whether or not you can inject at runtime. I'll have to do some digging to confirm!
Sep 22, 2021, 10:34 PM
I can see the projectId is baked into the build. 😞
so you know if theres a way I can inject a step into the build script to make this be defined by a query param or something? i.e. custom webpack step or sometihng?
Sep 22, 2021, 11:35 PM
I can see the projectId is baked into the build. 😞
so you know if theres a way I can inject a step into the build script to make this be defined by a query param or something? i.e. custom webpack step or sometihng?
Sep 22, 2021, 11:35 PM
i’m just inspecting if I can write a plugin that would acheive the above. but let me know if you do hear of anyone else who’s achieved.
Sep 23, 2021, 1:21 AM
success!!! i’ve worked it out!!!
Sep 23, 2021, 4:59 AM
success!!! i’ve worked it out!!!
Sep 23, 2021, 4:59 AM
by overriding the plugin i was able to inject my projectID from a query param.means Ishould be able to do multi tenency now
🙂
Sep 23, 2021, 5:00 AM
success!!! i’ve worked it out!!!
Sep 23, 2021, 4:59 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?