Skip to content

Commit

Permalink
fix: error out if studioBasePath looks like an absolute URL (#211)
Browse files Browse the repository at this point in the history
* Avoid improperly injecting an Astro route if a non-embedded Studio is used. Besides allowing proper operation with a separate Studio, this also avoids a rather misleading error and its message.

* A more clarifying solution to the separated-Studio problem, after conversation with @christianhg

* Alter to match changes made by @christianhg two days prior, after the fetch for latest had been taken.

* Simplify error message

---------

Co-authored-by: Christian Hamburger Grøngaard <[email protected]>
  • Loading branch information
narration-sd and christianhg authored Aug 29, 2024
1 parent 2f7e96c commit 9dc8b72
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/sanity-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default function sanityIntegration(
const clientConfig = integrationConfig
delete clientConfig.studioBasePath

if (!!studioBasePath && studioBasePath.match(/https?:\/\//)) {
throw new Error(
"[@sanity/astro]: The `studioBasePath` option should be a relative URL. For example — `studioBasePath: '/admin'`",
)
}

return {
name: '@sanity/astro',
hooks: {
Expand Down

0 comments on commit 9dc8b72

Please sign in to comment.