2017-12-23 5 views
0

개인 채널 인증을 시도 할 때 laravel-echo-server를 설정하면 오류가 발생합니다. 클라이언트를 인증 할 수 없으며 HTTP 상태 404가 발생합니다.laravel-echo-server 404 인증을 시도 할 때

공개 채널 인증 작업 중.

//channels.php

Broadcast::channel('private-test', function($user) { 
return true; 
}); 

// 전단 스크립트는 전용 채널에 대한 인증

window.Echo.private('private-test') 
.listen('TestMessage', (e) => { 
    app.updateChat(e); 
}); 

//laravel-echo-server.json

{ 
"authHost": "basic.test", 
"authEndpoint": "/broadcasting/auth", 
"clients": [], 
"database": "redis", 
"databaseConfig": { 
    "redis": {}, 
    "sqlite": { 
     "databasePath": "/database/laravel-echo-server.sqlite" 
    } 
}, 
"devMode": false, 
"host": null, 
"port": "6001", 
"protocol": "http", 
"socketio": {}, 
"sslCertPath": "", 
"sslKeyPath": "", 
"sslCertChainPath": "", 
"sslPassphrase": "", 
"apiOriginAllow": { 
    "allowCors": false, 
    "allowOrigin": "", 
    "allowMethods": "", 
    "allowHeaders": "" 
    } 
} 

//bootstrap.js

window._ = require('lodash'); 

/** 
* We'll load jQuery and the Bootstrap jQuery plugin which provides support 
* for JavaScript based Bootstrap features such as modals and tabs. This 
* code may be modified to fit the specific needs of your application. 
*/ 

try { 
    window.$ = window.jQuery = require('jquery'); 

    require('bootstrap-sass'); 
} catch (e) {} 

/** 
* We'll load the axios HTTP library which allows us to easily issue requests 
* to our Laravel back-end. This library automatically handles sending the 
* CSRF token as a header based on the value of the "XSRF" token cookie. 
*/ 

window.axios = require('axios'); 

window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken; 
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 

/** 
* Next we will register the CSRF Token as a common header with Axios so that 
* all outgoing HTTP requests automatically have it attached. This is just 
* a simple convenience so we don't have to attach every token manually. 
*/ 

let token = document.head.querySelector('meta[name="csrf-token"]'); 

if (token) { 
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 
    window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 
} else { 
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 
} 

/** 
* Echo exposes an expressive API for subscribing to channels and listening 
* for events that are broadcast by Laravel. Echo and event broadcasting 
* allows your team to easily build robust real-time web applications. 
*/ 

import Echo from 'laravel-echo' 

// window.Pusher = require('pusher-js'); 

// window.Echo = new Echo({ 
//  broadcaster: 'pusher', 
//  key: 'your-pusher-key' 
// }); 

window.Echo = new Echo({ 
    broadcaster: 'socket.io', 
    host: window.location.hostname + ':6001' 
}); 

단순히 내 laravel echo가 public/js의 app.js에서로드되면 bootstrap.js의 모든 라이브러리가로드됩니다. AFAIK, 올바른 자바 스크립트 또는 프런트 엔드 구문을로드하는 데 문제가 없습니다.

공개 채널을 추가하고 메시지를 보낼 수는 있지만 비공개 채널을 인증 할 수는 없습니다.

제안 사항이 있습니까?

답변

0

(오랫동안이 문제를 해결하기 위해 노력해온) 가장 오래 동안 내가 놓친 것을 발견했습니다. 설정/app.php

App\Providers\BroadcastServiceProvider::class, 

에서

는 (명백하게) 주석 처리되어야한다.

관련 문제