Problem with the SvelteKit SDK.
Hi! I tried to integrate Kinde with my exiting Sveltekit 2 project, I have followed the official documentation here https://kinde.com/docs/developer-tools/sveltekit-sdk/ . But everytime I visted the /api/auth/login and /api/auth/register the server returned 500 error and this is what was shown in the server terminal. I have no idea why this error occurred.
Kinde Docs
SvelteKit SDK - Developer tools - Help center
Our developer tools provide everything you need to get started with Kinde.
4 Replies
We have
sessionStorage
exported. So, can you use sessionStorage.getItem()
and see if that works for you?Thank you, I'll let you know the result.
I works as expected, thank you.
One more thing, I want to integrate Kinde with a Laravel backend but only serve as an API only and will receive auth token or a JWT from the authenticated frontend. Is it possible?
I suspect I might have answered this somewhere else for you 🤔
Yes, it's possible to integrate Kinde with a Laravel backend that serves as an API. The SvelteKit frontend can handle the authentication using Kinde, and then pass the JWT or auth token to the Laravel backend for subsequent requests.
Here's a general idea of how you can do it:
In your SvelteKit frontend, you can use the Kinde SvelteKit SDK to handle the authentication. The SDK provides methods to handle login, logout, and also to check if a user is authenticated. You can find more details in the SvelteKit SDK documentation.
Once the user is authenticated, you can get the access token using the getToken method provided by the SDK. This token is what you'll send to your Laravel backend.
In your Laravel backend, you'll need to verify the token in each request to ensure it's valid. You can do this by checking the token against the Kinde issuer URL and the audience (which should be your Laravel API).
Remember, the token should be sent in the Authorization header of your requests to the Laravel API. Here's an example of how you can do this:
Please note that this is a general guide and you might need to adjust based on your specific use case and setup. If you need more detailed help, feel free to ask!
Yea sorry, I was the one reach out through intercom😆
Thanks anyway