encore
encore copied to clipboard
Middleware Data and Redirection without Raw. | Encore Port of Better Auth
Related PR: https://github.com/encoredev/encore/pull/1631?new_mergebox=true
First, the way middleware works makes it a great fit for TypeScript to shine in encore.ts, unlike how it is required to be expressed in Go. The arrangement also complements this.
I decided to port Better-Auth to support Encore natively. but, here is the blocker delaying progress without resorting to api.raw, as I want to leverage all of Encore's benefits:
Blocker:
- The ability to set and get data in middleware.
- The ability to redirect either in a handler or in middleware.
I would have asked for Zod support, but I noticed that removing Zod resolved the issue and made it more Encore-native. While I suspect there might still be some limitations, things are moving smoothly so far. I also aim to use this issue to track any problems if I come across any.
I believe this will be a valuable contribution to the community at large, enabling developers to quickly spin up authentication for their projects without sacrificing what makes Encore interesting or relying on external services. You can read more about the motivation for this project here: https://github.com/solarsoft0/better-auth/issues/1
I currently have a copy in my personal project that I am working with, and I plan to sync it with the repo once things are stable. Considering the urgency of getting authentication out of the way, I may resort to a forklift migration, which I would rather avoid. I would greatly appreciate it if we could resolve these issues as soon as possible.
Thank you for making this amazing framework!
I think https://github.com/encoredev/encore/pull/1631 should solve both the problems. Redirects will be possible through custom status code and setting headers
yeah, I am currently using a forklift migration, and it feels like a black hole. maybe I'm getting too used to encore, I would love us to see this through as soon as we can, I will keep this issue up, to track anything else I may come across until we have encore-better-auth. thanks! @fredr.
The middleware pr have been released now (version 1.45.3), you can update encore by running encore version update
Hello,
@solarsoft0 what is the status of Encore.ts & Better-auth integration?
@carere just seeing this, i have been busy with other stuff, I am just about to pick this up again. Tomorrow we should have an update as regards this.
@solarsoft0, is there any news about better-auth and encore integration?
yes! https://github.com/solarsoft0/encore-better-auth/pull/2 this PR will seal it up.