webcontainer-core icon indicating copy to clipboard operation
webcontainer-core copied to clipboard

API integration not working (CORS issue?)

Open danpreiss opened this issue 1 year ago • 2 comments

Describe the bug

I have spent the better part of two days and millions of tokens trying to resolve this issue. I noticed today that a new feature was released around Request Relay that I would think have solved this issue for me but alas no success. I am trying to implement this API, which works when I run in the console but continue to receive errors when I have Bolt implement in the react app. I've even tried corsproxy.io.

https://supadata.ai/en/documentation/youtube/get-transcript

Link to the blitz that caused the error

https://bolt.new/~/sb1-p8cny9tv

Steps to reproduce

  1. Go to Tester in the left nav
  2. Click run test
  3. View console

Note: I did not try locally but this seems like a webcontainer issue

Expected behavior

Should fetch the youtube transcript

Parity with Local

Screenshots

image

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

danpreiss avatar Dec 18 '24 17:12 danpreiss

Issue Analysis Report

Current Behavior

  1. The transcript fetching functionality is failing silently with an empty error object
  2. The Vite proxy configuration is not effectively handling the requests
  3. Network requests are not visible in browser dev tools
  4. The error appears to be happening at the initial fetch attempt

What Has Been Tried

  1. Direct API calls to Supadata (failed due to CORS)
  2. CORS proxy through corsproxy.io (removed)
  3. Vite proxy configuration attempting to forward requests
  4. Multiple retry mechanisms in the fetch logic

Technical Investigation

  1. Request Flow
  2. Client makes request to /api/transcript
  3. Vite proxy should intercept and forward to Supadata
  4. Response should come back through proxy
  5. Client code handles response/errors

Key Issues Identified The Vite proxy configuration may not be loading correctly because:

  • Config imports may be circular or failing
  • Environment variables might not be available during proxy setup
  • Proxy headers might not be properly forwarded

Error handling is losing information because:

  • Empty error objects in catch blocks
  • Multiple layers of error transformation
  • Async stack traces being lost

Network isolation in WebContainer:

  • Limited network access
  • Proxy needs special configuration for WebContainer environment
  • CORS headers may be stripped

danpreiss avatar Dec 18 '24 18:12 danpreiss

@danpreiss Supadata founder here. I just accidentally stumbled upon this issue.

have you tried the Supadata SDK https://github.com/supadata-ai/js? Perhaps this approach can unblock you.

rafalzawadzki avatar Apr 20 '25 19:04 rafalzawadzki