简体   繁体   中英

Pusher auth endpoint gives me a 404 error

I am using pusher-js in react. My frontend is served at app.xxx.com and my backend is served at api.xxx.com. We have a private notification websocket channel to push notiifcations through app.xxx.com. What i'm trying to achieve is using the auth endpoint on backend. But no matter what i do, pusher will always request to the base URL of frontend plus auth endpoint. In my case it will be https://app.xxx.com/broadcasting/auth but i want it to be https://api.xxx.com/broadcasting/auth . What should i do? Here's my pusher config:

pusher = new Pusher(APP_ID, {
                httpHost: process.env.REACT_APP_WS_HOST,
                authEndpoint: '/broadcasting/auth',
                auth: {
                    params: {
                        id: userData.id,
                    },
                    headers: {
                        'X-CSRF-Token': '{{ csrf_token() }}'
                    }
                },
                cluster: 'ap2',
                wsHost: process.env.REACT_APP_WS_HOST,
                wsPort: 6001,
                wssPort: 6001,
                forceTLS: true,
            })

The value of process.env.REACT_APP_WS_HOST is api.xxx.com

UPDATE :
I even tried adding an authHost key but nothing changed.

您应该能够使用端点的完整 URL:

authEndpoint: 'https://api.xxx.com/broadcasting/auth'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM