<@U04UQ68083H> I'm using node ory client, how can ...
# ory-copilot
a
@chilly-king-10285 I'm using node ory client, how can I configurate timeout limit
b
A message from kapa.ai
You can configure timeout limits when using the Ory Node.js client by setting the
timeout
option in the
baseOptions
parameter when initializing the client. Here's an example of how to set a timeout limit of 5000 milliseconds (5 seconds) when initializing the Ory Kratos client:
Copy code
js import { V0alpha2Api, Configuration } from '@ory/kratos-client';  export const kratos = new V0alpha2Api(new Configuration({     basePath: '<https://custom.domain/api/kratos/public>',     baseOptions: {         withCredentials: true,         timeout: 5000,     }, }));
This configuration sets a 5-second timeout for all requests made through this client instance. You can adjust the timeout value according to your specific requirements. The example above is taken from a real-world implementation where a user was configuring CORS with a custom domain [Github Issue (closed): Cors doesn't seem to be activated with a custom domain on ory cloud](https://github.com/ory/network/issues/124). Remember that setting appropriate timeout values is important for handling network latency and ensuring your application remains responsive even when the Ory API might be experiencing delays.
a
@chilly-king-10285 how can I do it with
IdentityApi
and
Configuration
from
@ory/client
b
A message from kapa.ai
You can configure timeout limits with
IdentityApi
and
Configuration
from
@ory/client
using a similar approach. Here's how to set it up:
Copy code
javascript import { Configuration, IdentityApi } from "@ory/client"  const identity = new IdentityApi(   new Configuration({     basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`,     accessToken: `${process.env.ORY_ACCESS_TOKEN}`,     baseOptions: {       timeout: 5000, // Set timeout to 5000ms (5 seconds)       withCredentials: true,     },   }), )
This configuration sets a 5-second timeout for all requests made through the
IdentityApi
instance. You can adjust the timeout value based on your specific requirements. The pattern is consistent across different Ory APIs when using the
@ory/client
package - you always provide the timeout in the
baseOptions
object when creating a new
Configuration
instance.