-
-
Notifications
You must be signed in to change notification settings - Fork 609
Storage mounts with dynamic configuration #1161
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
Comments
Configuration from As a workaround, you can use a runtime plugin to mount in app context using import redis from "unstorage/drivers/redis";
export default defineNitroPlugin(() => {
const storage = useStorage();
storage.mount(
"/redis",
redis({
// ... options from runtime config, app config or process.env
})
);
}); |
If possible, I would still prefer to have some way of use process.env in config. |
Would it be possible to document the temporary workaround as mentioned by @pi0 (#1161 (comment)) inside Nuxt documentation? Would be happy to open a PR for this! Thanks (: |
PR also welcome for nitro docs to mention workaround in storage section 👍🏼 |
Sorry for necro but is there a way to do this for the cache system too? Is the only way here to override every single |
you might need to call |
same question |
When I create a plugin using the following code import redisDriver from 'unstorage/drivers/redis'
import azureAppConfigurationDriver from 'unstorage/drivers/azure-app-configuration'
export default defineNitroPlugin((nuxtApp) => {
const storage = useStorage()
if (useRuntimeConfig().systemRuntimeType == 'azure') {
storage.unmount('cache')
const azure = azureAppConfigurationDriver({
prefix: "default",
label: "cache",
})
storage.mount('cache', azure)
} else {
storage.unmount('cache')
const redis = redisDriver({
url: "redis://localhost:6379",
})
storage.mount('cache', redis)
}
}) The following error occurred ERROR [nuxt] [request error] [unhandled] [500] Cannot access 'nitroApp' before initialization 20:03:46
at Object.onRequest (/D:/my-nuxt-template/.nuxt/prerender/chunks/runtime.mjs:6801:7)
at Object.handler (/D:/my-nuxt-template/node_modules/h3/dist/index.mjs:1959:21)
at toNodeHandle (/D:/my-nuxt-template/node_modules/h3/dist/index.mjs:2266:17)
at callHandle (/D:/my-nuxt-template/node_modules/unenv/runtime/fetch/call.mjs:25:12)
at ufetch (/D:/my-nuxt-template/node_modules/unenv/runtime/fetch/index.mjs:9:23)
at Object.localFetch (/D:/my-nuxt-template/.nuxt/prerender/chunks/runtime.mjs:6821:39)
at /D:/my-nuxt-template/.nuxt/prerender/chunks/runtime.mjs:3162:36 How can I solve this problem? |
After testing, this state will only appear when the database is cache |
@pi0 I think this is a problem that needs to be solved urgently. Even the most basic ones can't be used. . . |
I will pick on this issue later. There is a workaround to mount drivers using nitro plugin and feed any dynamic configuration to id from various sources. Ideally more unstorage drivers should support environment variables or we support an interpolation support (self assigned issue to pick on this later) If you encounter any issues with workaround, please consider reporting in new issue with minimal nitro reproduction 🙏🏼 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature
relates nuxt/nuxt#20195
The examples in the above discussions are fairly common,
maybe provide a function to escape?
Additional information
The text was updated successfully, but these errors were encountered: