/api/socket help

cristiandev914 days ago

My situation is as follows: I have an ec2 server with traccar server installed and properly working, I already have a load balancer, ssl certificate, reverse proxy, and the api runs perfectly on that server. I'm creating a react js project with vite that will be hosted on AWS Amplify. Locally my frontend project executes the following information:

  server: {
    port: 3000,
    proxy: {
      '/api/socket': 'ws://api.server.com.br',
      '/api': 'https://api.server.com.br',
    },
  },

this works locally, at localhost:3000/api -> returns api data and the socket at /api/socket.
In amplify there is Rewrites and redirects, I have already made the following configuration:
/api/<*> -> redirects to -> https://api.server.com.br/api/<*>
/api/socket -> redirects to -> ws://api.server.com.br/api/socket,
both are type 200 (Rewrite).

In amplfy it's not working, do you know how to help me?

Anton Tananaev14 days ago

Shouldn't it be wss:// instead of ws://?

cristiandev914 days ago

I tried it both ways

cristiandev913 days ago

I solved it by implementing the build on the same server. your solution is incredible, thank you and congratulations.