ancient-dentist-17854
04/04/2025, 10:13 AMbrief-egg-61061
04/04/2025, 10:13 AMbrief-egg-61061
04/04/2025, 10:14 AMtimeout
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: 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.ancient-dentist-17854
04/04/2025, 10:15 AMIdentityApi
and Configuration
from @ory/client
brief-egg-61061
04/04/2025, 10:15 AMbrief-egg-61061
04/04/2025, 10:15 AMIdentityApi
and Configuration
from @ory/client
using a similar approach. Here's how to set it up: 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.