How can I send secure API requests from SvelteKit app, without showing API keys on the client side?
See original GitHub issueI’m using Supabase for a new Sveltekit app, with this template (https://github.com/joshnuss/svelte-supabase)
Currently, I’m passing the Supabase keys through on the client side, like this:
const supabase = createClient(
import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_ANON_KEY
)
What is the simplest way that I can create a secure backend/API, so the application can fetch content from Supabase, without showing Supabase key on the client side?
Is there any functionality built into Sveltekit that enables me to do this? Or would I need to integrate a backend like Rails?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:17 (4 by maintainers)
Top Results From Across the Web
How can I send secure API requests from SvelteKit app ...
What is the simplest way that I can create a secure backend/API, so the application can fetch content from Supabase, without showing Supabase ......
Read more >Types • Docs • SvelteKit
internal requests (e.g. for +server.js routes) go directly to the handler function when running on the server, without the overhead of an HTTP...
Read more >How to avoid exposing your API key in your public front-end ...
The Problem All you want to do is fetch some JSON from an API endpoint for ... that can send the appropriate POST...
Read more >API Routes/Endpoints in SvelteKit - YouTube
If you find my content useful and want to support the channel, you can now become a channel member! https://hbyt.us/joinSvelteKit is a ...
Read more >Migrating Breaking Changes in SvelteKit - Netlify
js that will only run on the server making it safe for API keys and secure SDKs you don't want leaked to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
enabling github discussions could also be an option
@AleCandido it doesn’t matter if it’s static or dynamic. In order to generate a static website, you need to run the whole app and get the pages. In order to get the pages you have to perform the request to the API. In my case I was forwarding the requests via a middleware and adding the secret API key.
That’s why I was confused and would like the docs to describe it in details. The middleware was a really nice thing to have in sapper and can slow down the development/transition to kit.
I solved my problem with an endpoint that forwards every request, though it doesn’t feel the right approach…