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

Support runtimeConfig #32

Closed
P4sca1 opened this issue Oct 22, 2020 · 6 comments
Closed

Support runtimeConfig #32

P4sca1 opened this issue Oct 22, 2020 · 6 comments

Comments

@P4sca1
Copy link

P4sca1 commented Oct 22, 2020

Right now the accessToken is compiled into the plugin. Would be great if storyblok would support nuxt runtimeConfig.
Example how @nuxtjs/axios implemented it: nuxt-community/axios-module@351ea5e

@flozero
Copy link

flozero commented Jan 15, 2021

I have added the support in my pr :)

@madStitcher
Copy link

Where is this feature? We've come to realize that we cannot use Storyblok with our Nuxt site unless it supports runtimeConfig, or another method of utilizing a preview key in our non production environments, and a public key on our production environment without recompiling the source.

@julia-utenkova
Copy link

I have added the support in my pr :)

Hi! Can you please explain/show how? :(

@coremyslo
Copy link

There is a workaround.

I'm using preview token for all envs, and just keep version draft/published in publicRuntimeConfig

Per docs:

To make the API as explorable as possible, accounts have draft versions and published version of API tokens. To access the draft version of your content you can use the preview token, and for receiving published content you can use the public token. The preview token is able to also load the published content. To switch between those versions you can append the query parameter version=draft/published and using the appropriate token to perform a draft or published version call.

Setup Example:

// .env.development
STORYBLOK_API_KEY = some_preview_token
STORYBLOK_VERSION = draft
// .env.production
STORYBLOK_API_KEY = some_preview_token
STORYBLOK_VERSION = published
// nuxt.config.js
publicRuntimeConfig: {
    ...
    storyblokVersion: process.env.STORYBLOK_VERSION,
    ...
}
// vue file
const response = await this.$storyapi.get(path, {
  "version": this.$config.storyblokVersion,
});

@julia-utenkova
Copy link

@coremyslo Perfect workaround, thanks a lot! Still requires to add version manually on every request.. but that's the best we have now!

@Dawntraoz
Copy link
Contributor

As this issue was created when this module was used for Nuxt 2, we will focus on the support on the new issue -> #217 and close this one.

For the same issue in the Nuxt 2 module, go to -> https://github.com/storyblok/storyblok-nuxt-2/issues

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 a pull request may close this issue.

6 participants