-
Notifications
You must be signed in to change notification settings - Fork 271
No Access-Control-Allow-Origin Headers Present When Running on Browser #483
Comments
👋 while it should be possible to get our gRPC based libraries working in the browser (the process is detailed here). This is not something we support out of the box. It might be worth commenting on the linked issue, regarding your requirements for CORS headers, if it doesn't seem like the process outlined would address this issue for you. |
Did you manage to get it working? In your Example https://github.com/lauchness/dialog-flow, you only used the REST API. Im currently facing the same CORS issue, trying to implement an Electron Dialogflow client |
@boehmrn I ended up just building an express server to handle the SessionsClient utilities. At one point I had it working somewhat after passing OAuth2 in the constructor for SessionsClient, but it would only work for a Google Account with access to the bot, so it wasn't ideal. I haven't tried since early December though, and I know there have been updates since then. |
@lauchness Thanks for the quick reply. Because I want to handle streaming audio, setting up a express server (or socket server) increases the complexity. So it would be way more appealing to handle the SessionClient directly in the browser. I am using the same account for creating the Dialogflow agent und for the client. May you pass a Hint how you overcame the cors issue. how did you succeed? Is there an account setting? |
I had first set up OAuth2 and used the response from that in the Constructor for the SessionsClient. To set up OAuth2 you need to have a page which sends the user to the Google Auth page, and then another page to handle the redirect back from google with the token as a query param. It's outlined here: https://developers.google.com/identity/protocols/OAuth2UserAgent Once you've got that taken care of the SessionsClient will work as expected, but like I said, in my experience this only worked if the Google Account used in OAuth2 had access to the dialogflow agent. Sorry if it's not much help. I didn't go to deep into this once I abandoned using the browser. |
@lauchness |
@boehmrn It will probably be worth it in the end anyway, good luck! Feel free to look here and see how I did it: https://github.com/lauchness/dialog-flow-server |
This issue might no longer be relevant due to its age. Feel free to re-open. |
Expected
When using the dialogflow.SessionsClient class, I would expect to be able to make calls to the dialogflow API and receive the appropriate CORS headers in the response.
Actual
When using the SessionsClient
detectIntent
method, the response from the dialogflow API doesn't contain the appropriate CORS headers (specifically "Access-Control-Allow-Origin"), preventing me from using this package in a browser.Note: I used the auth parameter in the SessionsClient constructor outlined here: #405 (comment)
Environment details
dialogflow
version: 0.14.1Steps to reproduce
Initialize
SessionsClient
class on Client application with OAuth2Client from google-auth-library package following these instructions: You need to pass auth instance to gRPC-fallback client. Use OAuth2Client from google-auth-library #405 (comment)Call detectIntent method from client application following the method in the dialogflow docs
The text was updated successfully, but these errors were encountered: