sanner
sanner
Explore posts from servers
CDCloudflare Developers
Created by sanner on 9/2/2024 in #workers-help
knex+workers TypeError
I was working with Cloudflare Workers + bun & Hono and was using Knex as my orm. I was successfully ably to make a connection on Cloudlfare Pages to Knex+Postgres with Connection Pooling however on Workers I am recieving a TypeErorr. I tried using both the connectionString and specifiying the individual parameters for the database. Additionally I set node_compat = true and also added the
node:
node:
prefix previously when using compatibility_flags = ["nodejs_compat"] I also played around with the version numbers of both the sql connection adapter
pg
pg
and
Error:
Error:
javascript [wrangler:err] TypeError: this.driver.Client is not a constructor at Client_PG._acquireOnlyConnection (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/dialects/postgres/index.js:81:24) at Client_PG.acquireRawConnection (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/dialects/postgres/index.js:99:17) at create (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/client.js:262:39)
Error Source:
Error Source:
javascript knex({ client: 'pg', // Replace 'pg' with your database client if different connection: { host: "hostDB", port: 5432, user: "postgres", password: "passwordDB", database: "databaseName", ssl: { rejectUnauthorized: false, }, }, searchPath: ['knex', 'public'], // Optional: Specify search path for PostgreSQL }); ```
1 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #pages-help
OATUH Cloudflare Pages
I was developing trying to implement github oauth on cloudfare pages using a beta branch. the production branch is define as another branch and the production branch contains the main url. It works locally but not on cloudflare pages my oauth flow looks like this at the moment
export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);

context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}
export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);

context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}
25 replies
CDCloudflare Developers
Created by sanner on 8/27/2024 in #general-help
Cloudflare Pages Oauth (Google/Github)
I was developing trying to implement github oauth on cloudfare pages using a beta branch. the production branch is define as another branch and the production branch contains the main url. It works locally but not on cloudflare pages my oauth flow looks like this at the moment
export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);

context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}
export async function GET(context: APIContext): Promise<Response> {
const state = generateState();
const url = await github.createAuthorizationURL(state);

context.cookies.set("github_oauth_state", state, {
path: "/",
secure: DEPLOYED_ENV,
httpOnly: true,
maxAge: 60 * 10,
sameSite: "lax"
});

const responseBody = {
url: url.toString()
};
const response = new Response(JSON.stringify(responseBody), {
status: 200,
headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*"
}
});
return response;
}
3 replies