FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
rozek
rozekUserSpecificResource
Public
Like
UserSpecificResource
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
1/27/2025
README.md

Sometimes you want a val to be public (e.g., to give others the chance to inspect and fork it) but not to be callable by everybody (e.g., because you are accessing some resources which are rate limited or expensive)

The simplest approach to meet both requirements is to require an authorization of type "Bearer" with a (random) token that is stored in a Val.Town environment variable. Such variables are specific to the owner of a val and - since the val is running on the server - cannot be inspected be the caller.

As a consequence, only clients knowing the correct token can run the val, but everybody can inspect and fork it in order to use the val with his/her own environment setting.

To experiment with this val, please fork it and define an environment variable called "UserSpecificResource" with whatever you want to use as an access token (e.g., a UUID or a random number)

Some tests can be found in val UserSpecificResource_Test

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.