If I use the following code in Next.js I get an er...
# talk-kratos
q
If I use the following code in Next.js I get an error:
Copy code
export const oryBrowserClient = new V0alpha2Api(new Configuration(edgeConfig));
Which gives
Copy code
Error: connect ECONNREFUSED 127.0.0.1:80
But
Copy code
export const oryBrowserClient = new V0alpha2Api(
  new Configuration({ ...edgeConfig, basePath: `${configuration.BASE_URL_SITE}/api/.ory` }),
);
works 😕 I am following the example on GitHub
b
Can you elaborate your issue a bit more and your usage of calls to Kratos?
👍 1
q
Sure, I mostly just copied the code from https://github.com/ory/kratos-selfservice-ui-react-nextjs and am doing the exact same thing in the login, registration etc. pages but getting the above error when I visit e.g.
/login
b
My best guess is that because your file does not exist in pages/api directory as given by the ory team in their example but in a separate utils folder in a completely different directory structure from where it's getting imported. The reason it works when you give the BASE_URL_SITE is that the server is then finally able to receive the fully qualified url unlike the previous scenario.
q
They have a client in a separate folder as well as the
[…paths]
page and so do I
Like I said, it works fine using the
basePath
so I’m not too bothered, but the reason why I was wondering about it is that I have a completely different problem related to my frontend not sending cookies to my backend which could have something to do with this (but maybe not). Locally everything works fine, but when I deploy my website (boilerplate.live) and my backend (api.boilerplate.live) it sends requests fine (no CORS issue) but doesn’t include cookies. I’ve no idea if it has anything to do with how I’ve set Ory up or not
I’ve tried putting Ory under ory.boilerplate.live, but if I do that I get a 500 error on my Next.js app that it can’ find
/api/.ory/<any path here>
😕 works fine if I use the default URL given by Ory Cloud though
b
I faced a not quite but similar issue while setting up my configuration where it was unable to find the Ory path because of oathkeeper issues where it was deployed on 4455 while my nextjs app was on 3000. I ended up setting up a variable for url path which I'm unable to recollect the exact name of at the moment in my nextjs config file.
If that doesn't help, I'm sure tagging any of the ory team members would be helpful
q
Thanks for your help @brash-gpu-27606