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

Why leak the key? #1

Open
mattpilott opened this issue Sep 14, 2023 · 1 comment
Open

Why leak the key? #1

mattpilott opened this issue Sep 14, 2023 · 1 comment
Labels
question Further information is requested

Comments

@mattpilott
Copy link

Why do you leak the access token here?

https://github.com/roberto-butti/my-storyblok-sveltekit-example/blob/main/src/storyblok.js

@roberto-butti
Copy link
Owner

Hi, good question.
The token here is a public token. It is not a personal access token.
And this function is a "multi-purpose" function that you can use in the client and server sides.

But if you want to "protect" your access token and you are building a server-side-only project, using the .server files, you can rename the env variable from PUBLIC_ to SECRET_ for example:

import { SECRET_ACCESS_TOKEN } from '$env/static/private'

Another thing to evaluate is using static or dynamic in the import statement.

A nice article: https://joyofcode.xyz/sveltekit-environment-variables#static-for-variables-during-the-build-process

Did I understand your question correctly?

@roberto-butti roberto-butti added the question Further information is requested label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants