Soo's avatar
Level 2

how to connect react to pusher

i have this erreur : POST http://localhost:3000/pusher/auth 404 (Not Found) how can i resolve it , the back (laravel) work but in front the notification has not showing what can i do my friends.

0 likes
2 replies
JeremyL's avatar

Have you run php artisan route:clear and do you see that route on the Larvel side?

Alternatively, if you are not using Laravel you could look to this to make sure the route is present:

import React from 'react';
import { Route, IndexRoute } from 'react-router';
import reactRouterToArray from 'react-router-to-array';
// or var reactRouterToArray = require('react-router-to-array');

console.log(reactRouterToArray(
  <Route path="/" component={FakeComponent}>
    {/* just to test comments */}
    <IndexRoute component={FakeComponent} />
    <Route path="about" component={FakeComponent}>
      <Route path="home" component={FakeComponent} />
      <Route path="/home/:userId" component={FakeComponent} />
    </Route>
    <Route path="users" component={FakeComponent} />
    <Route path="*" component={FakeComponent} />
  </Route>)
); //outputs: ['/', '/about', '/about/home', '/users']

You'd have to install react-router-to-array

1 like
Soo's avatar
Level 2

@JeremyL the probleme is the server send the notification succusfully and in the browser of pusher i show the notification but in front react no in the network tools the requete of websocket is still pendig like this: 451a6537bf687c7dcc?protocol=7&client=js&version=8.4.0-rc2&flash=false /app/63451a6537bf687c7dcc ws://ws-mt1.pusher.com/app/63451a6537bf687c7dcc?protocol=7&client=js&version=8.4.0-rc2&flash=false GET 101 websocket ws ws-mt1.pusher.com websocket NotificationsComponent.jsx:14 0 B Pending

Please or to participate in this conversation.