Straegge
Straegge
KKinde
Created by Straegge on 4/24/2025 in #💻┃support
Kinde in Cloudflare Pages Function Middleware
Okay so I've added and verified a custom domain, and I can see the cookies set in the browser, but your suggestion still doesn't work. In the request coming to the CF Pages Function middleware, the "Authorization" header is still null. And the cookies still don't seem to be passed correctly, at least there's no token cookie present in the request. I realized you said "via custom domain cookies or Authorization header you manually attach" - I can't manually attach anything, it's a middleware managed by CF that is automatically executed for every request going to the site. Can you please verify your solution?
8 replies
KKinde
Created by Straegge on 4/24/2025 in #💻┃support
Kinde in Cloudflare Pages Function Middleware
Thanks for the confirmation. So replacing the values with my own doesn't work, that URL gives me the following error: Something went wrong when we tried to authenticate you, and we can’t offer a quick way out. Start a new session and try signing in again. Error code: 1656 But additionally adding the code_challenge and code_challenge_method parameters seems to work, at least the URL directs me to the sign-in page. I really wish there was an easier to get there, as in Clerk - like why do I need to specify the redirect_uri? It should be optional and Kinde should default to the homepage callback URL specified in the app. On that note, is there a suggested way of generating the state parameter? I don't really care about it for this middleware functionality, but the URL doesn't work without it.
8 replies
KKinde
Created by Straegge on 4/24/2025 in #💻┃support
Kinde in Cloudflare Pages Function Middleware
Basically I just want to direct the user to the same page as when using the login method of the SDKs. Is there a way to do that within a Cloudflare Pages Function without reimplementing the login function internals?
8 replies
KKinde
Created by Straegge on 4/24/2025 in #💻┃support
Kinde in Cloudflare Pages Function Middleware
Thanks for your reply, that explains things. I'll set up a custom domain then. I don't need help with verifying the token, but I am wondering about redirecting from the CF Function if the token is not valid. With Clerk, I can simply redirect to https://<clerk-ui-domain>/sign-in. But Kinde doesn't seem to have a simple sign-in route, and since I can't use the SDK, it looks like I have to redirect to: https://<your_kinde_subdomain>.kinde.com/oauth2/auth ?response_type=code &client_id=<your_kinde_client_id> &redirect_uri=<your_app_redirect_url> &scope=openid%20profile%20email &state=abc Is my understanding correct or is there a simpler URL?
8 replies