-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(studio): add
CorsOriginErrorScreen
- Loading branch information
1 parent
75129af
commit e1b976d
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
packages/sanity/src/studio/screens/CorsOriginErrorScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {Card, Dialog, Stack, Button, Text} from '@sanity/ui' | ||
import React, {useCallback} from 'react' | ||
|
||
interface CorsOriginErrorScreenProps { | ||
projectId?: string | ||
} | ||
|
||
export function CorsOriginErrorScreen(props: CorsOriginErrorScreenProps) { | ||
const {projectId} = props | ||
|
||
const corsUrl = `https://sanity.io/manage/project/${projectId}/settings/api` | ||
const origin = window.location.origin | ||
|
||
const handleRetry = useCallback(() => { | ||
window.location.reload() | ||
}, []) | ||
|
||
return ( | ||
<Card height="fill"> | ||
<Dialog | ||
id="cors-error-dialog" | ||
header="Error" | ||
width={1} | ||
footer={ | ||
<Stack paddingX={3} paddingY={2}> | ||
<Button text="Retry" onClick={handleRetry} /> | ||
</Stack> | ||
} | ||
> | ||
<Stack paddingX={4} paddingY={5} space={4}> | ||
<Text> | ||
It looks like the error is being caused by the current origin (<code>{origin}</code>) | ||
not being allowed for this project. | ||
</Text> | ||
|
||
<Text> | ||
If you are a project administrator or developer, you can head to{' '} | ||
<a rel="noopener noreferrer" target="_blank" href={corsUrl}> | ||
the project management | ||
</a>{' '} | ||
interface to configure CORS origins for this project. | ||
</Text> | ||
|
||
<Text> | ||
<a | ||
href="https://www.sanity.io/docs/front-ends/cors" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Read more about CORS Origins | ||
</a> | ||
. | ||
</Text> | ||
</Stack> | ||
</Dialog> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters