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

Next.js basePath handling #45

Open
RokoTechnology opened this issue Jan 4, 2023 · 2 comments
Open

Next.js basePath handling #45

RokoTechnology opened this issue Jan 4, 2023 · 2 comments

Comments

@RokoTechnology
Copy link

RokoTechnology commented Jan 4, 2023

I am running OpenFAAS based setup with multiple servers on different sub paths of same domain - mydomain.com/function/app1, mydomain.com/function/app2 etc.

Now i'm trying to set up a Next + Ory app at mydomain.com/function/nextapp

I am using Next.js 12 with @ory/client 1.1.4 and @ory/integrations 1.1.0

I have a basePath: '/function/nextapp' in my next.config.js because I need the ory login pages to live on mydomain.com/function/nextapp/api/.ory/ui/login instead of mydomain.com/api/.ory/ui/login

Unfortunately, no matter what I try, I always end up being redirected to mydomain.com/api/.ory/ui/login?flow=...

  • I tried manually going to the URL mydomain.com/function/nextapp/api/.ory/ui/login
  • I tried explicitly redirecting the user to the absolute url such as router.push('mydomain.com/function/nextapp/api/.ory/ui/login')
  • I tried explicitly overriding the edgeConfig.basePath to /function/nextapp/api/.ory/ when instantiating FrontendApi such as new FrontendApi(new Configuration({ basePath: 'mydomain.com/function/nextapp/api/.ory/ui/login' }))

Looks like the currently suggested Next + Ory setup ignores the next.config.js basePath and it is not possible to override it manually either.
Looks like the FrontendApi ignores edgeConfig and always redirects to the root relative basePath /api/.ory/ui/login

@RokoTechnology
Copy link
Author

actually, i think the root cause is not in the FrontendApi but in the @ory/integrations/next-edge here

"/api/.ory",

@RokoTechnology
Copy link
Author

i made a PR which should resolve my issue. you could pass appBasePath: myNextConfig.basePath to the createApiHandler

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

No branches or pull requests

1 participant