Skip to content

Commit

Permalink
Fix local links from docs to Storybook (#624)
Browse files Browse the repository at this point in the history
* Redirect Storybook link from docs site to Storybook dev server

* Add safeguard to avoid redirects in prod environments

Theoretically you should only hit this page in dev environments because
primer.style's reverse proxy redirects this directory to the SB instance,
but when that configuration changes we don't want to expose this local
redirect.
  • Loading branch information
pouretrebelle authored Jul 18, 2024
1 parent 598a2c5 commit 9d3d525
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/docs/src/pages/brand/storybook.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* This page is only used during local development to redirect Storybook links to the Storybook dev server
* On production this directory is redirected to the privately hosted Storybook by primer.style
*/

import {useEffect} from 'react'

const StorybookRedirect = ({location}) => {
useEffect(() => {
if (process.env.NODE_ENV === 'development') {
window.location.replace(`http://localhost:6006${location.search}`)
}
}, [])

return null
}

export default StorybookRedirect

0 comments on commit 9d3d525

Please sign in to comment.