unrealspeech / unrealspeech-react-sdk

0 stars 0 forks source link

CORS is not enabled on the unrealspeech APIs #1

Open ericlink opened 2 weeks ago

ericlink commented 2 weeks ago

Hello - thanks for the sample. I was having trouble using the javascript examples in the api playground, with CORS, so gave this a try. I'm having the same trouble with this sample. CORS is not working on the APIs and there are fetch errors:

localhost/:1  Access to fetch at 'https://api.v6.unrealspeech.com/speech' from origin 'http://localhost:3000' 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.
App.js:45 

        POST https://api.v6.unrealspeech.com/speech net::ERR_FAILED
(anonymous) @ tslib.es6.mjs:316
(anonymous) @ tslib.es6.mjs:121
s @ tslib.es6.mjs:117
_makePostRequest @ tslib.es6.mjs:316
(anonymous) @ tslib.es6.mjs:316
(anonymous) @ tslib.es6.mjs:121
s @ tslib.es6.mjs:117
speech @ tslib.es6.mjs:316
(anonymous) @ tslib.es6.mjs:316
(anonymous) @ tslib.es6.mjs:121
s @ tslib.es6.mjs:117
speech @ tslib.es6.mjs:316
handleSpeech @ App.js:45
callCallback @ 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:26179
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 27 more frames
Show less
App.js:45  Error making POST request: TypeError: Failed to fetch
    at a.<anonymous> (tslib.es6.mjs:316:1)
    at Generator.next (<anonymous>)
    at tslib.es6.mjs:121:1
    at new Promise (<anonymous>)
    at s (tslib.es6.mjs:117:1)
    at a._makePostRequest (tslib.es6.mjs:316:1)
    at a.<anonymous> (tslib.es6.mjs:316:1)
    at Generator.next (<anonymous>)
    at tslib.es6.mjs:121:1
    at new Promise (<anonymous>)
ericlink commented 2 weeks ago

I'm using the sample react app from the readme, cut and pasted into a generated react app with the npm installed: npm install unrealspeech-react-sdk --legacy-peer-deps

(standard npm install gives errors btw)

$ npm install unrealspeech-react-sdk
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree