hoppscotch-backend icon indicating copy to clipboard operation
hoppscotch-backend copied to clipboard

WSS 400 Error

Open hyperxpro opened this issue 2 years ago • 4 comments

I have properly configured the backend service but when the front end tries to establish a WSS connection, it gets a 400 error. I also tried to connect to "wss://localhost:8989/graphql/ws" using Postman but still getting Error: Unexpected server response: 400.

Can you please help?

hyperxpro avatar Feb 06 '23 20:02 hyperxpro

I changed environment: "production" to environment: "development" and it started working perfectly. Is the production setting not supported?

hyperxpro avatar Feb 07 '23 09:02 hyperxpro

When you use environment development, it will allow CORS request from any domain. The fix would probably be setting environment to production and configuring the setting allowed_domains correctly.

jerbob92 avatar Feb 07 '23 11:02 jerbob92

api:
  port: "8989"
  # development/production/test
  environment: "production"
  ssl:
    enabled: false
    certificate: "/etc/api-config/ssl.crt"
    key: "/etc/api-config/ssl.key"
database:
  username: "hoppscotch"
  password: "hoppscotch"
  database: "hoppscotch"
  host: "localhost"
  port: "3306"
  driver: "mysql"
  debug: true
allowed_domains: # This is to allow CORS to do it's magic.
  - "https://hoppscotch.example.com"
  - "https://api-hoppscotch.example.com"

The first domain is the frontend domain and the second one is the backend API domain. Just changing production to development makes things work perfectly. Nothing else I change.

hyperxpro avatar Feb 07 '23 12:02 hyperxpro

At this moment I would not know what would cause that, since the only thing the environment changes is the logging and enabling CORS.

jerbob92 avatar Feb 07 '23 15:02 jerbob92