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: support useRuntimeConfig(event) in all presets without unenv #1318

Closed
wants to merge 12 commits into from

Conversation

Hebilicious
Copy link
Contributor

@Hebilicious Hebilicious commented Jun 18, 2023

πŸ”— Linked issue

fix: #272
related: #1150

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This allows cloudflare environment variables to use runtimeConfig without unenv unjs/unenv#95
Assuming the following environment variables are bound to the worker :

NITRO_HELLO="world"
NUXT_HELLO_THERE="general"
SECRET="secret"

The following will work as expected :

export default eventHandler((event) => {
  useRuntimeConfig(event).hello  //world
  useRuntimeConfig().helloThere //general
  useRuntimeConfig().secret //undefined
});

Note that using event is optional.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Jun 18, 2023

Codecov Report

Merging #1318 (bcc3e40) into main (9ce2f64) will not change coverage.
Report is 2 commits behind head on main.
The diff coverage is n/a.

❗ Current head bcc3e40 differs from pull request most recent head 3c0b64b. Consider uploading reports for the commit 3c0b64b to get more accurate results

@@           Coverage Diff           @@
##             main    #1318   +/-   ##
=======================================
  Coverage   76.38%   76.38%           
=======================================
  Files          73       73           
  Lines        7550     7550           
  Branches      745      746    +1     
=======================================
  Hits         5767     5767           
  Misses       1782     1782           
  Partials        1        1           

@nuxt-studio
Copy link
Contributor

nuxt-studio bot commented Jun 19, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
nitro Edit on Studio β†—οΈŽ View Live Preview 3c0b64b

src/runtime/config.ts Outdated Show resolved Hide resolved
@Hebilicious Hebilicious changed the title feat: support cloudflare env in runtimeConfig feat: support cloudflare env in runtimeConfig without unenv Aug 7, 2023
@Hebilicious Hebilicious marked this pull request as draft August 7, 2023 08:57
@Hebilicious Hebilicious changed the title feat: support cloudflare env in runtimeConfig without unenv feat: support useRuntimeConfig(event) in all presets without unenv Aug 7, 2023
@Hebilicious
Copy link
Contributor Author

Hebilicious commented Aug 7, 2023

Closing in favour of #1547 and #1549

@Hebilicious Hebilicious closed this Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support cloudflare environment variables
2 participants