简体   繁体   English

Pusher auth 端点给我一个 404 错误

[英]Pusher auth endpoint gives me a 404 error

I am using pusher-js in react.我在反应中使用pusher-js My frontend is served at app.xxx.com and my backend is served at api.xxx.com.我的前端在 app.xxx.com 上提供服务,而我的后端在 api.xxx.com 上提供服务。 We have a private notification websocket channel to push notiifcations through app.xxx.com.我们有一个私人通知 websocket 通道,可以通过 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.但无论我做什么,pusher 总是会请求前端加上 auth 端点的基本 URL。 In my case it will be https://app.xxx.com/broadcasting/auth but i want it to be https://api.xxx.com/broadcasting/auth .就我而言,它将是https://app.xxx.com/broadcasting/auth但我希望它是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 process.env.REACT_APP_WS_HOST值为api.xxx.com

UPDATE :更新
I even tried adding an authHost key but nothing changed.我什至尝试添加一个authHost密钥,但没有任何改变。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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