Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js specific defaults for new projects #7465

Merged
merged 1 commit into from
Sep 10, 2024
Merged

Next.js specific defaults for new projects #7465

merged 1 commit into from
Sep 10, 2024

Conversation

SimeonGriggs
Copy link
Contributor

Description

When running sanity init inside a Next.js project, this will:

  • Default the name of the .env file (if created) to .env.local as this is what Next.js .gitignore targets
  • Create a new CORS origin for Next.js default http://localhost:3000 so that the user isn't prompted to do so the first time they open the Studio

What to review

I would've thought there'd be somewhere else in the codebase where this check-first-then-add-CORS logic would already exist, but couldn't find it, so recreated it.

Testing

Create a new Next.js project

npx create-next-app@latest --tailwind --ts --app --src-dir --eslint --import-alias "@/*"

Within it, run the below (but obviously targeting your local build)

npx sanity init

Notes for release

  • When sanity init is run inside a Next.js project, an appropriate CORS origin is added to the project
  • When sanity init is run inside a Next.js project, environment variables are written to an .env.local file

@SimeonGriggs SimeonGriggs requested a review from a team as a code owner September 4, 2024 10:22
@SimeonGriggs SimeonGriggs requested review from cngonzalez and removed request for a team September 4, 2024 10:22
Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 10:30am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 10:30am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 10:30am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 10:30am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 10:30am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Sep 4, 2024 10:30am

Copy link
Contributor

github-actions bot commented Sep 4, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Sep 4, 2024

Component Testing Report Updated Sep 4, 2024 10:35 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 32s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 43s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 47s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 13s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 25s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 34s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@bjoerge bjoerge added this pull request to the merge queue Sep 10, 2024
Merged via the queue into next with commit b04d30c Sep 10, 2024
41 of 42 checks passed
@bjoerge bjoerge deleted the next-init-cors branch September 10, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants