stu
stu
Explore posts from servers
CDCloudflare Developers
Created by stu on 4/13/2025 in #general-help
Hostname 'www.<my-domain>.com' already has externally managed DNS records
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "project-name",
"main": "./dist/_worker.js/index.js",
// Update to today's date
"compatibility_date": "2025-03-25",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"binding": "ASSETS",
"directory": "./dist"
},
"observability": {
"enabled": true
},
"vars": {},
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": <hyperdrive-id>,
"localConnectionString": <local-connection-string>
}
],
"routes": [
{
"pattern": "www.<my-domain>.com",
"custom_domain": true
}
]
}
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "project-name",
"main": "./dist/_worker.js/index.js",
// Update to today's date
"compatibility_date": "2025-03-25",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"binding": "ASSETS",
"directory": "./dist"
},
"observability": {
"enabled": true
},
"vars": {},
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": <hyperdrive-id>,
"localConnectionString": <local-connection-string>
}
],
"routes": [
{
"pattern": "www.<my-domain>.com",
"custom_domain": true
}
]
}
I'm trying to configure a simple test site. I have a custom domain, and previously added it to Cloudflare. So DNS records are populated. But then adding "routes" to wrangler, when I deploy, I get the error Hostname 'www.<my-domain>.com' already has externally managed DNS records (A, CNAME, etc). Either delete them, try a different hostname, or use the option 'override_existing_dns_record' to override. [code: 100117] Are there specific DNS entries I need to delete to get this working?
2 replies
BABetter Auth
Created by stu on 4/13/2025 in #help
Hanging timeout server-side requests using Cloudflare Hyperdrive
Anyone have success using Cloudflare Hyperdrive with Better-Auth? Basically, I have sign-in functionality server-side like:
const result = await auth(env).api.signInEmail({
body: {
email,
password,
},
asResponse: true,
});
const result = await auth(env).api.signInEmail({
body: {
email,
password,
},
asResponse: true,
});
But it's hanging forever when I hit it. No logs, just forever loading. Auth looks like:
export const auth = (env: Env) =>
betterAuth({
database: {
dialect: new PostgresJSDialect({
postgres: getDb(env), // Call getDb() as a function to create a new connection each time
}),
// dialect,
type: "postgres",
},
emailAndPassword: {
// email and password stuff
},
secret: BETTER_AUTH_SECRET,
});
export const auth = (env: Env) =>
betterAuth({
database: {
dialect: new PostgresJSDialect({
postgres: getDb(env), // Call getDb() as a function to create a new connection each time
}),
// dialect,
type: "postgres",
},
emailAndPassword: {
// email and password stuff
},
secret: BETTER_AUTH_SECRET,
});
And getDb function looks like:
export function getDb(env: Env) {
// Connection URL from environment variables
let connectionString = env.HYPERDRIVE.connectionString;

const sql = postgres(connectionString, {
max: 5,
// idle_timeout: 30,
ssl: import.meta.env.DEV,
// Debug options - remove in production
debug: true,
fetch_types: false,
});

return sql;
}
export function getDb(env: Env) {
// Connection URL from environment variables
let connectionString = env.HYPERDRIVE.connectionString;

const sql = postgres(connectionString, {
max: 5,
// idle_timeout: 30,
ssl: import.meta.env.DEV,
// Debug options - remove in production
debug: true,
fetch_types: false,
});

return sql;
}
If I use the postgres connectionString directly, it works. But if I use the Hyperdrive connectionString, it hangs. Any ideas?
7 replies
BABetter Auth
Created by stu on 4/2/2025 in #help
Invalid token on resetPassword
I'm creating a flow for when a signed out user forgets their password, they can reset it.
export const auth = betterAuth({
database: {
dialect,
type: "postgres",
},
emailAndPassword: {
enabled: true,
sendResetPassword: async (
{ user, token, url }: { user: User; token: string; url: string },
_
) => {
await sendResetPasswordEmail({
email: user.email,
url,
});
},
resetPasswordTokenExpiresIn: 3600, // 1 hour
},
trustedOrigins: ["http://localhost:4321"],
});
export const auth = betterAuth({
database: {
dialect,
type: "postgres",
},
emailAndPassword: {
enabled: true,
sendResetPassword: async (
{ user, token, url }: { user: User; token: string; url: string },
_
) => {
await sendResetPasswordEmail({
email: user.email,
url,
});
},
resetPasswordTokenExpiresIn: 3600, // 1 hour
},
trustedOrigins: ["http://localhost:4321"],
});
It's sending me an email with a URL like http://localhost:4321/reset-password/<TOKEN>. Great! But when I try and use the token to reset the password, I always get a BAD_REQUEST with error INVALID_TOKEN. I'm trying to resetPassword server-side, and the code looks like this:
const result = await auth.api.resetPassword({
body: {
newPassword: password,
token,
},
});
const result = await auth.api.resetPassword({
body: {
newPassword: password,
token,
},
});
17 replies