Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run at different paths (has to run at root) #125

Open
raphaeltm opened this issue Jan 3, 2025 · 2 comments · May be fixed by #126
Open

Unable to run at different paths (has to run at root) #125

raphaeltm opened this issue Jan 3, 2025 · 2 comments · May be fixed by #126

Comments

@raphaeltm
Copy link
Contributor

raphaeltm commented Jan 3, 2025

I was testing out a setup running in a Next.js api route. Basically I think what I'll be working on might require a few screens that are pretty tightly coupled to auth, so I'd like to keep everything together in a Next app. So I figured I'd setup OpenAUTH in an api route under /api/auth. But that didn't work because there was no way to tell the Hono app that I needed it to run at the /api/auth base path, which needs to happen before the routes get added to it, if I understand correctly.

It seems like every place that needs to generate an OpenAUTH based url (like issuer, etc.) isn't configurable to handle this. I've started to put together a PR to allow for this (and perhaps other server configurations) but as I work on it I'm realizing that there are probably a bunch of spots where this would need to be added and I'm not sure it makes sense for me to dig through them all at the moment.

On a related note, I had trouble with things like adding the app to a route under another Hono app as well. I kept getting

hono typeerror: cannot access invalid private field (evaluating 'app.#errorhandler')

despite the fact that I used the same pinned version of Hono.

@raphaeltm raphaeltm linked a pull request Jan 3, 2025 that will close this issue
@thdxr
Copy link
Contributor

thdxr commented Jan 3, 2025

so the challenge here is some of the routes cannot be changed - eg /.well-known/jwks.json always needs to be there and cannot be at a subpath

but the other paths should be allowed to - i need to come up with an example of this and figure out what needs to change internally

@raphaeltm
Copy link
Contributor Author

Hmm... I didn't realize that. Just read RFC 5785 and I guess I understand why.

I guess the use-case of integrating directly in a Next.js app becomes a bit more complicated, then. I guess you'd have to register the app in a couple different routes for it to work. I could see it being useful to some people. In my case, I'll find a different path forward for what I was testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants