bxr
bxr
Explore posts from servers
BABetter Auth
Created by bxr on 4/17/2025 in #help
sign in stuck loading in deployed app
Hi there, I have an issue I am encountering in my deployed app but not local app. When I try to sign-in the user gets successfully authenticated but the loading button is stuck loading. This issue does not happen locally (of course 😂 ) and I am not too sure why that's happening. I know the request response shows redirect = false but the same is shown locally and the user gets redirected to their profile. I use @daveycodez's better-auth library but I don't think that's the issue
function RouteComponent() {
const { pathname } = Route.useParams();

return (
<>
<AuthCard
pathname={pathname}
socialLayout="auto"
redirectTo="/profile"
classNames={{ title: "text-center", description: "text-center" }}
/>
</>
);
}
function RouteComponent() {
const { pathname } = Route.useParams();

return (
<>
<AuthCard
pathname={pathname}
socialLayout="auto"
redirectTo="/profile"
classNames={{ title: "text-center", description: "text-center" }}
/>
</>
);
}
could it be a different issue? I also don't see the session being set in the in the browser cookies which leads to me believe that could be an issue as well. I use tanstack start but with a separate elysiajs backend where better-auth is located
45 replies
BABetter Auth
Created by bxr on 4/13/2025 in #help
Provider invalid OAuth2 redirect_uri
No description
7 replies
BABetter Auth
Created by bxr on 4/5/2025 in #help
reset-password not working with email link
No description
82 replies
BABetter Auth
Created by bxr on 3/4/2025 in #help
stripe multiple subscription for one customer id
Quick question with the stripe plugin I see the following disclaimer:
For each reference ID (user or organization), only one active or trialing subscription is supported at a time. The plugin doesn't currently support multiple concurrent active subscriptions for the same reference ID.
For each reference ID (user or organization), only one active or trialing subscription is supported at a time. The plugin doesn't currently support multiple concurrent active subscriptions for the same reference ID.
Does that mean an user can only have 1 subscription at a time? My app has multiple subscriptions for different products, that wouldn't be possible then? What's confusing in the docs is that there's the client.subscription.list() To get the user's active subscriptions which sounds counterintuitive with the previous disclaimer
5 replies
BABetter Auth
Created by bxr on 2/28/2025 in #help
openapi not showing commands
I set up the openAPI plugin as showed in the docs, but the commands are not showing as shown in the attached video. I am using ElysiaJS and drizzleorm my auth:
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
password: {
hash: Bun.password.hash,
verify: ({ password, hash }) => Bun.password.verify(password, hash),
},
},
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
},
},
plugins: [openAPI()],
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "user",
input: false,
},
},
},
});

export const betterAuthView = (context: Context) => {
const BETTER_AUTH_ACCEPT_METHODS = ["POST", "GET"];
if (BETTER_AUTH_ACCEPT_METHODS.includes(context.request.method)) {
console.log(context.request);
return auth.handler(context.request);
}

context.error(405);
};

export const authService = new Elysia().all("/api/auth/*", betterAuthView);
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
password: {
hash: Bun.password.hash,
verify: ({ password, hash }) => Bun.password.verify(password, hash),
},
},
socialProviders: {
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
},
},
plugins: [openAPI()],
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "user",
input: false,
},
},
},
});

export const betterAuthView = (context: Context) => {
const BETTER_AUTH_ACCEPT_METHODS = ["POST", "GET"];
if (BETTER_AUTH_ACCEPT_METHODS.includes(context.request.method)) {
console.log(context.request);
return auth.handler(context.request);
}

context.error(405);
};

export const authService = new Elysia().all("/api/auth/*", betterAuthView);
import { Elysia } from "elysia";
import { listingsRouter } from "./routes/listings";
import { authService } from "./libs/auth/auth";

const app = new Elysia()
.use(authService)
.use(listingsRouter) // Mounts listings routes
.onError(({ code, error, set }) => {
console.log(error);
if (code === "VALIDATION") {
set.status = 400;
return { message: "Bad Request", details: error.message };
}
// Default status set in route-specific handlers
return { message: error.message };
})
.listen(8080);

console.log(
`🦊 Mercury backend running at ${app.server?.hostname}:${app.server?.port}`,
);
import { Elysia } from "elysia";
import { listingsRouter } from "./routes/listings";
import { authService } from "./libs/auth/auth";

const app = new Elysia()
.use(authService)
.use(listingsRouter) // Mounts listings routes
.onError(({ code, error, set }) => {
console.log(error);
if (code === "VALIDATION") {
set.status = 400;
return { message: "Bad Request", details: error.message };
}
// Default status set in route-specific handlers
return { message: error.message };
})
.listen(8080);

console.log(
`🦊 Mercury backend running at ${app.server?.hostname}:${app.server?.port}`,
);
8 replies
DTDrizzle Team
Created by bxr on 11/29/2023 in #help
Supabase/postgres get query is stuck on prod app
No description
25 replies
DIAdiscord.js - Imagine an app
Created by bxr on 11/28/2023 in #djs-questions
Member Permissions for subcommand groups?
Are we able to add member permissions to subcommand groups? I have a SlashCommandBuilder command group for channel related actions. Some commands should only be available for admins and some for mods... But I only see that we are able to add DefaultMemberPermissions to the SlashCommandBuilder as a whole:
xport const channelSlashCommand: SlashCommandBuilder =
new SlashCommandBuilder()
.setName('channel')
.setDescription('Set of admin commands for channel management')
.addSubcommandGroup((group) =>
group
.setName('admin')
.setDescription('Add, remove, list channels from db')
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('Add chanel to DB')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Select the channel you want to set')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('type')
.setDescription("The channel's type")
.addChoices(
{ name: 'Announcement', value: 'announcement' },
{ name: 'General', value: 'general' },
{ name: 'Success', value: 'success' },
)
.setRequired(true),
)
.addRoleOption((option) =>
option
.setName('role')
.setDescription(
'Select the role you want to alert when sending messages to this channel',
),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('delete')
.setDescription('delete a channel from db')
.addStringOption((option) =>
option
.setName('channel_id')
.setDescription('Enter the channel ID')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName('list').setDescription('List current channels'),
),
)
.addSubcommandGroup((group) =>
group
.setName('mod')
.setDescription('Channel management commands for mods')
.addSubcommand((subcommand) =>
subcommand
.setName('lock')
.setDescription('Lock a channel')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Channel to lock')
.setRequired(true),
),
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
xport const channelSlashCommand: SlashCommandBuilder =
new SlashCommandBuilder()
.setName('channel')
.setDescription('Set of admin commands for channel management')
.addSubcommandGroup((group) =>
group
.setName('admin')
.setDescription('Add, remove, list channels from db')
.addSubcommand((subcommand) =>
subcommand
.setName('add')
.setDescription('Add chanel to DB')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Select the channel you want to set')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('type')
.setDescription("The channel's type")
.addChoices(
{ name: 'Announcement', value: 'announcement' },
{ name: 'General', value: 'general' },
{ name: 'Success', value: 'success' },
)
.setRequired(true),
)
.addRoleOption((option) =>
option
.setName('role')
.setDescription(
'Select the role you want to alert when sending messages to this channel',
),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName('delete')
.setDescription('delete a channel from db')
.addStringOption((option) =>
option
.setName('channel_id')
.setDescription('Enter the channel ID')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName('list').setDescription('List current channels'),
),
)
.addSubcommandGroup((group) =>
group
.setName('mod')
.setDescription('Channel management commands for mods')
.addSubcommand((subcommand) =>
subcommand
.setName('lock')
.setDescription('Lock a channel')
.addChannelOption((option) =>
option
.setName('channel')
.setDescription('Channel to lock')
.setRequired(true),
),
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
5 replies
DTDrizzle Team
Created by bxr on 8/14/2023 in #help
Default value for Array creates an incorrect SQL migration
I'm currently adding a new field roles to my PG table, users, such as:
export const users = pgTable(
'users',
{
user_id: text('user_id').primaryKey(),
balance: integer('balance').notNull().default(0),
roles: text('roles').array().default(['user']),
},
(table) => {
return {
user_idIdx: uniqueIndex('user_id_idx').on(table.user_id),
};
},
);
export const users = pgTable(
'users',
{
user_id: text('user_id').primaryKey(),
balance: integer('balance').notNull().default(0),
roles: text('roles').array().default(['user']),
},
(table) => {
return {
user_idIdx: uniqueIndex('user_id_idx').on(table.user_id),
};
},
);
The problem is that when I generate the SQL schema it returns this:
ALTER TABLE "users" ADD COLUMN "roles" text[] DEFAULT user;
ALTER TABLE "users" ADD COLUMN "roles" text[] DEFAULT user;
which is wrong since it thinks it's referencing to a user table but not just a default string value called user
1 replies
DTDrizzle Team
Created by bxr on 7/16/2023 in #help
Module '"drizzle-orm/mysql-core"' has no exported member 'unique'.ts(2305)
Getting this error when trying to import unique
import {
text,
unique, // erroring out
mysqlTable,
serial,
mysqlEnum,
} from 'drizzle-orm/mysql-core';
import {
text,
unique, // erroring out
mysqlTable,
serial,
mysqlEnum,
} from 'drizzle-orm/mysql-core';
13 replies
DTDrizzle Team
Created by bxr on 7/11/2023 in #help
mysql-core fails on TS build on 0.27.1
Getting this error when I try to build my ts node app
3 replies