jerbob92 / hoppscotch-backend

MIT License
68 stars 20 forks source link

WSS 400 Error #9

Open hyperxpro opened 1 year ago

hyperxpro commented 1 year ago

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 commented 1 year ago

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

jerbob92 commented 1 year ago

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.

hyperxpro commented 1 year ago
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.

jerbob92 commented 1 year ago

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