Hey folks,
I’m encountering some problems with the websocket functionality. Everything runs smoothly when I’m testing my project locally through Wappler. However, once I upload the project onto my server, the websocket refuses to cooperate. Initially, it wouldn’t connect at all. My project is hosted on the server using a reverse proxy, and I’ve configured the settings in the .htaccess file accordingly.
RewriteOptions inherit
# RewriteRule ^/?$ "https\:\/\/example\.com\/Login" [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "https\:\/\/example\.com\/" [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule ^socket\.io/$ ws://localhost:3000/socket.io/ [P,L]
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Update: I managed to resolve the connection issue by implementing a rewrite rule. However, I’m facing a new challenge now. When I emit something from the API, it doesn’t reflect in the frontend application. Any assistance on this matter would be greatly appreciated.