dialogflow-javascript-client icon indicating copy to clipboard operation
dialogflow-javascript-client copied to clipboard

Access-Control-Allow-Origin issue

Open ghost opened this issue 7 years ago • 18 comments

Failed to load https://api.api.ai/v1/query?v=20150910: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

ghost avatar Oct 12 '18 23:10 ghost

Is there anyone has the same issue can help me out

ghost avatar Oct 12 '18 23:10 ghost

I'm having a similar issue and additional warning, Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.api.ai/v1/query?v=20150910 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details. Any update would be appreciated.

ricas07 avatar Oct 12 '18 23:10 ricas07

change apiai.js this.uri = this.apiAiClient.getApiBaseUrl() + "query?v=" + this.apiAiClient.getApiVersion(); to this.uri = "https://cors-anywhere.herokuapp.com/" + this.apiAiClient.getApiBaseUrl() + "query?v=" + this.apiAiClient.getApiVersion();

ghost avatar Oct 13 '18 01:10 ghost

@zyzarvin1987 does your solution works, if sure can u please mention where should i need to change it.because i didn't see the above lines in apiai.js

Thanks.

latheesh08 avatar Oct 13 '18 05:10 latheesh08

@zyzarvin1987 I've confirmed this workaround enables you to get responses from dialogFlow, but you have to send your request to a third party, including the Authorization header which contains your token. The third party then forwards the response to you. This is a pretty big security issue, I would not recommend this as a solution. Any further update would be appreciated.

ricas07 avatar Oct 13 '18 17:10 ricas07

Just as an FYI, this is a server issue on Google's side. Hopefully they will fix it ASAP.

You can install cors-anywhere as a module on a server you control if you need the proxy capabilities but don't want to send your data to a third party: (https://www.npmjs.com/package/cors-anywhere)

fdavies93 avatar Oct 14 '18 18:10 fdavies93

My app Still not available for connect to dialoglflow.

it works fine 3 days ago,

what happend

"Failed to load https://api.api.ai/v1/query?v=20150910: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9008' is therefore not allowed access."

"Uncaught (in promise) ApiAiRequestError at new ApiAiBaseError (webpack-internal:///5:5:22) at new ApiAiRequestError (webpack-internal:///5:20:9) at TextRequest.handleError (webpack-internal:///6:32:21)"

"Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.api.ai/v1/query?v=20150910 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details."

bgbdsl avatar Oct 15 '18 06:10 bgbdsl

@bgbdsl Even I have the same issue. Can see the logs working for 3 days back. Today it has started giving CORS. Any luck yet?

ATakaSKY avatar Oct 15 '18 13:10 ATakaSKY

It seems like it fixed itself

berithpy avatar Oct 15 '18 18:10 berithpy

today, this issue happened again.

parkkichul avatar Mar 08 '19 05:03 parkkichul

this.uri = "https://cors-anywhere.herokuapp.com/" + this.apiAiClient.getApiBaseUrl() + "query?v=" + this.apiAiClient.getApiVersion();

this solution is not works, anybody, Is there anyone has the same issue can help me out

parkkichul avatar Mar 08 '19 05:03 parkkichul

@parkkichul got the same issue . Last time it resolved but now it's not working don't know why have to wait for the fix.. if anyone found the solution please share . thank you in advance.

latheesh08 avatar Mar 08 '19 05:03 latheesh08

https://cors-anywhere.herokuapp.com/https://api.api.ai/v1/query?v=20150910,

when I using cors-anywhere.herokuapp.com, it returned,

"Missing required request header. Must specify one of: origin,x-requested-with"

anybody help me out

parkkichul avatar Mar 08 '19 08:03 parkkichul

you should update your bot to v2 api, so you will not receive this issue any more

ghost avatar Mar 08 '19 16:03 ghost

@zyzarvin1987 is this module support v2. If so, tell me the procedure to migrate or any other module you know that support dialogflow v2 please ping me. thank you in advance

latheesh08 avatar Mar 09 '19 04:03 latheesh08

Hi, I am running into a similar issue attempting to use dialogflow v2, I am new to using HTTP, what sort of information would be useful for debugging this?

Tasininet avatar Aug 13 '19 20:08 Tasininet

The proper fix is to stop using dialogflow-javascript-client on the client side. Expose an endpoint in your backend app that will hand over the requests from the client to dialogflow library and pass the response back to client. This way you don't have to do any dramatic changes in your client app logic when it comes to handling response.

Cheers, Tomasz.

On Tue, Aug 13, 2019, 22:46 Tasininet [email protected] wrote:

Hi, I am running into a similar issue attempting to use dialogflow v2, I am new to using HTTP, what sort of information would be useful for debugging this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dialogflow/dialogflow-javascript-client/issues/102?email_source=notifications&email_token=ADJAU5UK256L3BTDFSUA6ILQEML2VA5CNFSM4F3JI3WKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4G5KQI#issuecomment-521000257, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJAU5WEJBLNBA5WABXE2NLQEML2VANCNFSM4F3JI3WA .

eisenek avatar Aug 13 '19 21:08 eisenek