OIDC /oauth2/authorize doesn't work / throws 404
Hello,
I'm currently working on setting up an OIDC Provider for an internal app (which serves as a central hub app, implementing a custom authentication solution that's exposed via better-auth plugins and should be available as an OAuth endpoint for other internal apps relying on the same authentication data). The authentication API itself is exposed on an express app / backend, whereas most of the client functionality (signing in, managing credentials) which all works flawlessly.
I've hit a roadblock, because the OIDC Provider /oauth2/authorize endpoint simply does not work. I've tried everything from using the generic example from the docs, to tweaking every single setting.
Here is the gist of what I'm doing:
CLIENT_URI resolves to a frontend application (NextJS, separate application and URL), that exposes the UI for interacting with better-auth. That seems to work as expected, since all other login flows seem to work (crossDomain cookies). Locally, they both resolve to localhost with varying ports (3000 for frontend, 3001 for express / backend). On production they'll eventually resolve to separate subdomains (e.g. frontend is
https://intranet
and express / backend will be https://api.intranet
).
When I now open the /oauth2/authorize path on my express server directly, with a properly constructed authorization URL, I just end up with a 404 blanko page.
All the other oauth2 endpoints work, or at least return codes that make sense (none of them returns 404) so I'm really at a loss, why the authorize endpoint fails to work. I've installed the openAPI Plugin in the development environment, seeing as that makes it easier to debug individual endpoints (and browse them).0 Replies