Fix examples URL in docs app (#4129)

Allow us to preview docs + examples changes on staging.tldraw.dev. Also
allow previewing the docs app on phones in local dev.

### Change type

- [x] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [ ] `other`
This commit is contained in:
David Sheldrick 2024-07-10 10:07:16 +01:00 committed by GitHub
parent 89d7438ca3
commit 76a5d98eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,7 +17,11 @@ export default function ExampleCodeBlock({
const { theme } = useTheme()
useEffect(() => setIsClientSide(true), [])
const SERVER =
process.env.NODE_ENV === 'development' ? 'http://localhost:5420' : 'https://examples.tldraw.com'
process.env.NODE_ENV === 'development'
? `http://${location.host}:5420`
: location.host.includes('staging') || location.host.includes('canary')
? `https://examples-canary.tldraw.com`
: 'https://examples.tldraw.com'
// This is to avoid hydration mismatch between the server and the client because of the useTheme.
if (!isClientSide) {