Closed thesocialdev closed 2 years ago
@aeneasr
Sorry to hear you are having trouble. What repository are you working with? Is there maybe a reproducible repo we can take a look at? I’m on vacation currently but maybe @Benehiko can help out here!
Thanks for the prompt response @aeneasr (please do not disrupt your vacation)
The code to reproduce it is in this PR https://github.com/AletheiaFact/aletheia/pull/342
I'm happy to walk you through setup and tests. But assuming you got into the setup through the readme, setting up the ory sdk credentials and accessing http://localhost:3000/ory-login should work
For context, the only difference from the examples is that I'm wrapping NextJS with NestJS, but still using NextJS Server to perform SSR.
I see, in that case the error probably happens because NestJS is dealing with the config differently and is parsing the HTTP body instead of passing it as a raw byte stream down to our systems. In NextJS we disable the body parser using a config value, not sure how that works in NestJS
@aeneasr that's spot on 🎯 the problem was the body parser
How did you fix it for NestJS? Might be helpful to others :)
@aeneasr the solution was to disable body parser for the application, you can see that in this line of code. If we need the body parser functionality we need to explicitly filter the endpoints through a middleware.
But now, ory is successfully integrated with our application
And for context, that's how I am enabling body parsing for endpoints not related to Ory integration: https://github.com/AletheiaFact/aletheia/pull/342/commits/de0812535e5187fa78796c038dfbdf11a9f9af43
Awesome thank you! @Benehiko could you organize that this makes it into our documentation so others working with NestJS don’t face the same difficulties? Thank you!
Will do :)
I'm getting this error with nextjs 14.2.4, not using nestjs. Anyone else?
Interesting, I downgraded from @ory/integrations 1.2.1 to 1.1.5 and it seems to work fine again. Any idea what may have happened between 1.1.5 and 1.2.1 to cause this with nextjs 14.2.4?
I have the same problem. It looks to me like the fetch
implementation is not working properly.
https://github.com/ory/integrations/blob/781878c3ecd7119c6a71bfd32d919b3f283d1a44/src/next-edge/index.ts#L110-L118
@jetaggart @teawithfruit Removing the imported config that disables body parser fixes it after the 1.2.0 update. Looks like the handler now expects the body to come parsed?
@david-on-github do you mind sharing some code or more explanation how you disabled the body parser? Not quite following.
@jetaggart
The config from the readme is shown being re-exported. https://github.com/ory/integrations?tab=readme-ov-file#nextjs
import { config, createApiHandler } from "@ory/integrations/next-edge"
export { config }
The config disables bodyparser for nextjs api routes. Just need to remove the export { config }
line since the function is treating the body as json.
I am having an error when trying to submit a login request to
path/to/ory/self-service/login?flow=
The error returned is a
400 Bad Request
I tried to manually forward the content-length from the
next-edge/createApiHandler
but then I gotECONNRESET
errorsHow can I proceed?