raidendotai/openv0

CORS issue - failed to fetch POST localhost:3000/components/new

dylanjha opened this issue · 1 comments

Running server:

~/code/misc/openv0/openv0_server
❯ node index.js
Server is running on port 3000 --------------------

{
  event: '> ./modules/export/react dump_webapp() started',
  warn: 'if webapp crashes because of invalid generated components\n' +
    'add componentId and version to ./generated/export_ignore.txt\n' +
    'then run `node export_refresh.js` from server folder'
}
{
  EXPORT_IGNORE: {
    './generated/export_ignore.txt': [
      'CodeSnippet_x7n4c',
      'ExampleBadComponent_aBc99 1695074919799',
      'FitnessCoachingPricingComponent_3IT9E 1695113383715'
    ]
  }
}

Running client:

~/code/misc/openv0/openv0_vitereact
❯  npm run dev

> react-vite-ui@0.2.1 dev
> vite


  VITE v4.4.9  ready in 255 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

Clicking "Generate" gets a CORS issue on POST /components/new

Access to fetch at 'http://localhost:3000/component/new' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
generate-new-component.tsx:28     POST http://localhost:3000/component/new net::ERR_FAILED
handleButtonClick @ generate-new-component.tsx:28
callCallback2 @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
(anonymous) @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26140
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
Show 15 more frames
Show less
generate-new-component.tsx:47 API request failed: TypeError: Failed to fetch
    at handleButtonClick (generate-new-component.tsx:28:30)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:25)
    at executeDispatch (react-dom.development.js:9041:3)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:7)
    at processDispatchQueue (react-dom.development.js:9086:5)
    at dispatchEventsForPlugins (react-dom.development.js:9097:3)
    at react-dom.development.js:9288:12
handleButtonClick @ generate-new-component.tsx:47
await in handleButtonClick (async)
callCallback2 @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
(anonymous) @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26140
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
Show 15 more frames
Show less

cors_2023-09-19_16-31-48

thats odd, cors is enabled on server
i've had similar errors before with adblock enabled - is that the case ?