Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Redirect sveltekit endpoint and pass data to page

$
0
0

I'm using oauth to signin to a service. Once signed in, the app redirects my app to the set redirect uri, which also points to my sveltekit endpoint (/callback). After I verify the code and get the token through the endpoint, I'd like to redirect/send the client back to the homepage, with the token data, but I cannot figure out how to.

What I've currently tried:

export async function get(response: IncomingRequest) {    if (response.query.has('code')) {        const code = response.query.get('code')        const url = `url endpoint to verify code above`        const verifiedCode = await fetch(url, {            method: 'POST',            headers: { 'Accept': 'application/json' }        })        if (verifiedCode) {            const data = await verifiedCode.json()            // redirect to homepage and give token to client            // tried:            return {                headers: {                    location: '/'                },                body: data,                status: 302            }        }    }}

Logging the response in the get() endpoint of my homepage results in the body being null regardless of what I put the body in this endpoint.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>