dialogflow / dialogflow-javascript-client

JavaScript Web SDK for Dialogflow
Apache License 2.0
412 stars 173 forks source link

Access-Control-Allow-Origin issue #102

Open ghost opened 6 years ago

ghost commented 6 years ago

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 commented 6 years ago

Is there anyone has the same issue can help me out

ricas07 commented 6 years ago

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.

ghost commented 6 years ago

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();

latheesh08 commented 6 years ago

@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.

ricas07 commented 6 years ago

@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.

fdavies93 commented 6 years ago

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)

bgbdsl commented 6 years ago

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."

ATakaSKY commented 6 years ago

@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?

berithpy commented 6 years ago

It seems like it fixed itself

ghost commented 6 years ago

Great news. By the way, if the issue happened again, we can setup a ourown proxy server to get the response

From: Diego Díaz notifications@github.com Sent: Monday, October 15, 2018 11:37 AM To: dialogflow/dialogflow-javascript-client dialogflow-javascript-client@noreply.github.com Cc: Arvin Zhou Yu.Zhou@csusb.edu; Mention mention@noreply.github.com Subject: Re: [dialogflow/dialogflow-javascript-client] Access-Control-Allow-Origin issue (#102)

It seems like it fixed itself

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dialogflow_dialogflow-2Djavascript-2Dclient_issues_102-23issuecomment-2D429967175&d=DwMFaQ&c=B_W-eXUX249zycySS1AyzjABMeYirU1wvo9-GmMObjY&r=j18R6e91-uITb7tox9tr5O50G_X5SA5qzhdx6ffYNPE&m=TDcLmVIgk0kZq6SSnVW8p1HpYFP7nchNjz-MT7n4NMc&s=FGiu8gGFwQn4l9_SRSFMKPIVG7PO1K5MobNUREq4ipc&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AeZEo8czpqPbtcDHjYnT7dgyVqGZMxylks5ulNXpgaJpZM4XaUbs&d=DwMFaQ&c=B_W-eXUX249zycySS1AyzjABMeYirU1wvo9-GmMObjY&r=j18R6e91-uITb7tox9tr5O50G_X5SA5qzhdx6ffYNPE&m=TDcLmVIgk0kZq6SSnVW8p1HpYFP7nchNjz-MT7n4NMc&s=LVyjn24JqE_gW30VzC5rN__xZN1ea15WJOcvm2qwP7w&e=.

parkkichul commented 5 years ago

today, this issue happened again.

parkkichul commented 5 years ago

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

latheesh08 commented 5 years ago

@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.

parkkichul commented 5 years ago

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

ghost commented 5 years ago

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

latheesh08 commented 5 years ago

@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

Tasininet commented 5 years ago

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?

eisenek commented 5 years ago

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 notifications@github.com 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 .