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

feat(nuxt): warn when accessing private runtimeConfig on client #26441

Merged
merged 6 commits into from
Jun 7, 2024

Conversation

nopeless
Copy link
Contributor

πŸ”— Linked issue

None

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I wasted a bit too much time having trouble why server hydration and client view was different until I realized that I was accessing useRuntimeConfig().<some prop> in client as well. This would prevent future issues like that

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Mar 22, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great idea! Thank you ❀️

However, I think as written it will warn when these keys are accessed on server side as well given that we are manipulating the config within the SSR renderer.

Maybe just warn on client side? (We could add the guard within the import.meta.client block within app/nuxt.)

@nopeless
Copy link
Contributor Author

I think this is a great idea! Thank you ❀️

However, I think as written it will warn when these keys are accessed on server side as well given that we are manipulating the config within the SSR renderer.

Maybe just warn on client side? (We could add the guard within the import.meta.client block within app/nuxt.)

SSR context is untouched. In fact, it exposes even more properties, specifically .nitro (which in my opinion makes more sense, let me know if this behaviour is not what you want)

only SPA context is altered

@nopeless nopeless marked this pull request as draft March 22, 2024 12:14
@nopeless nopeless force-pushed the improve-runtime-config-access-check branch from 118bbc4 to ed14aea Compare March 22, 2024 13:08
@nopeless
Copy link
Contributor Author

@danielroe when ssr: true the error is not triggered

@nopeless nopeless marked this pull request as ready for review March 22, 2024 13:15
@nopeless
Copy link
Contributor Author

nopeless commented Apr 3, 2024

bump

@danielroe
Copy link
Member

danielroe commented Apr 3, 2024

(This PR is waiting for a minor release - probably Nuxt v3.12. It has not been forgotten)

@danielroe danielroe changed the title feat: check access for secret values on runtime configuration when dev feat(nuxt): warn in dev mode when accessing unavailable keys from runtime configuration on client Jun 7, 2024
@danielroe danielroe changed the title feat(nuxt): warn in dev mode when accessing unavailable keys from runtime configuration on client feat(nuxt): warn when accessing private runtimeConfig on client Jun 7, 2024
@danielroe danielroe merged commit 601a262 into nuxt:main Jun 7, 2024
60 checks passed
@github-actions github-actions bot mentioned this pull request Jun 7, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants