Skip to content

Instantly share code, notes, and snippets.

View LukasCCB's full-sized avatar
🏠
Working from home

Skull LukasCCB

🏠
Working from home
View GitHub Profile
@LukasCCB
LukasCCB / gist:dbc89f2a70b4fbb3cdefd89fbb31aa6a
Last active September 25, 2024 10:29
How I Finally Solved Websocket SSL Issues in Laravel
I've encountered WebSocket issues in Laravel since Laravel 5, and it persisted through versions 9, 10, and now 11. The primary problem has always been getting WebSockets to run over WSS/HTTPS.
After numerous attempts, I found a solution to successfully run WebSocket over SSL. Here's how I did it.
Steps to Run WebSocket with SSL in Laravel
1. Generate SSL Certificates for your Domain or Host IP
First, generate the private key, CSR (Certificate Signing Request), and certificate for your domain (e.g., you-domain.net).
# Generate a private key
pm.sendRequest({
url: pm.environment.get('APP_URL') + 'sanctum/csrf-cookie',
method: 'GET'
}, function (error, response, { cookies }) {
if (!error) {
pm.environment.set('XSRF_TOKEN', cookies.get('XSRF-TOKEN'))
}
})