box / box-typescript-sdk-gen

Repository for generated Box TS SDK
Apache License 2.0
15 stars 3 forks source link

Unable to use SDK in Vercel serverless environment due to proxy-agent dependency. #310

Closed andrusch closed 2 months ago

andrusch commented 2 months ago

Description of the Issue

I've built a NextJS app and have included the Box SDK within some API routes. These routes work locally and also from a clean GitPod environment. When the NextJS route is deployed to Vercel, I receive the following error when trying to execute any of the API routes that include Box SDK.

Steps to Reproduce

  1. Create a NextJS starter project and place the lines of code below in an API route folder. This example is for demonstratable purposes only. Get Started with NextJS
  2. 
    import {
    BOX_CLIENT_ID,
    BOX_CLIENT_SECRET,
    BOX_CONTRACT_TEMPLATE_ID,
    BOX_ENTERPRISE_ID,
    BOX_USER_ID,
    } from '@/constants'
    import { BoxCcgAuth } from 'box-typescript-sdk-gen'

export async function GET( req: NextRequest ) { try { const authClient = new BoxCcgAuth({ config: this._config }); const tokenResponse = await authClient.withUserSubject(BOX_USER_ID as string).retrieveToken() return NextResponse.json({ success: true }, { status: 200 }) } catch (e) { return NextResponse.json({ success: false }, { status: 400 }) } }

3. Deploy to [Vercel.com](https://vercel.com/) with the free plan
4. Call the API from Postman 

### Expected Behavior

You should receive a 200

### Error Message, Including Stack Trace

⨯ Error: Cannot find module 'proxy-agent' Require stack:

Versions Used

Typescript SDK: "box-typescript-sdk-gen": "^1.1.0" Platform: Vercel Node.js (if applicable): 20x "typescript": "^5.3.3"

congminh1254 commented 2 months ago

Hi @andrusch

Can you take a look at this comment

Please let me know if it works for your case.

Bests, Minh

andrusch commented 2 months ago

Hey @congminh1254

Yep, this resolved the issue. Apologies for not finding that ahead of opening this.

Best, Charlie