sanner
sanner
Explore posts from servers
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
Thanks I guess I will look into and reevaluate whether to host my auth server on astro or worker+hono
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
Though the fellow uses vercel and hono as the adapter, now that I look at it again
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
4
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
why is that you are unable to interoperate hono+astro in a single hono project. I was looking at a tutorial in astro + hono on cloudflare.
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
For further context I have not used hono yet, though I intended to, currently I am using calling the api routes which are under the pages directory.
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
I am using a cloudflare adapater with hybrid rendering
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
I am using astro and the code is being invoked in a client side rendered svelte portion running inside astro within a pages directory which is typically used for routing in astro
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
which will allow me to mitigate many of these issues
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
I was thinking of potentially switching to hono with cloudflare
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
There is not necessarily an error it seems that the callback route is unable to be accessed on cloudflare, in the sense that a 404 is thrown when the callback is accesssed
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
So the main issue is, is that the oauth workflow works on localhost but not when deployed on cloudflare to the non-main branch. The main branch has a static url for both deployment url's the branch or link I am testing on does not have a static url but it does have a static alias The callback url is set to the alias url generated by cloudflare as opposed to the numeric url set to the branch.
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
Frontend
async function handleAuth() {
let realHref: string = href;
try {
const response = await fetch(realHref, { credentials: "include" });
const jsonResponse = await response.json();
let url = jsonResponse.url;
realHref = url;
console.log(jsonResponse);
if (url.includes("google")) {
realHref = addGoogleRedirectUri(url);
}
window.location.replace(realHref);
} catch (error) {
console.log(error);
}
}
async function handleAuth() {
let realHref: string = href;
try {
const response = await fetch(realHref, { credentials: "include" });
const jsonResponse = await response.json();
let url = jsonResponse.url;
realHref = url;
console.log(jsonResponse);
if (url.includes("google")) {
realHref = addGoogleRedirectUri(url);
}
window.location.replace(realHref);
} catch (error) {
console.log(error);
}
}
callback
context.cookies.set("auth-session", cookieString, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});
await setUserSession(
cookieString,
{
username_tag: userId,
profile_picture_url: googleUser.picture,
}
).catch((error) => {
console.error(error);
return new Response("Unable to set user session", {
status: 500,
});
});
return context.redirect("/postsignup");
context.cookies.set("auth-session", cookieString, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});
await setUserSession(
cookieString,
{
username_tag: userId,
profile_picture_url: googleUser.picture,
}
).catch((error) => {
console.error(error);
return new Response("Unable to set user session", {
status: 500,
});
});
return context.redirect("/postsignup");
25 replies