Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxtjs + VUE 2 to update vue 3 + vite not working echo #375

Closed
saifulbdDev opened this issue Mar 14, 2023 · 2 comments
Closed

Nuxtjs + VUE 2 to update vue 3 + vite not working echo #375

saifulbdDev opened this issue Mar 14, 2023 · 2 comments

Comments

@saifulbdDev
Copy link

saifulbdDev commented Mar 14, 2023

`
Screenshot_23
this nuxt code working good

import Echo from "laravel-echo";

window.Pusher = require("pusher-js");

export default function ({ $axios }, inject) {
  // const echo = new Echo({
  //   broadcaster: "pusher",
  //   key: "",
  //   cluster: "ap1",
  //   forceTLS: true,
  // });

  const echo = new Echo({
    broadcaster: "pusher",
    key: process.env.BROADCAST_APP_KEY,
    cluster: process.env.BROADCAST_APP_CLUSTER,
    forceTLS: true,
    authorizer: (channel, options) => {
      return {
        authorize: (socketId, callback) => {
          $axios
            .$post("/broadcasting/auth", {
              socket_id: socketId,
              channel_name: channel.name,
            })
            .then((response) => {
              callback(false, response);
            })
            .catch((error) => {
              callback(true, error);
            });
        },
      };
    },
  });

  inject("echo", echo);
}

this vite and vue 3 code not working

import Echo from "laravel-echo";
import axios from "@/lib/axios";
import Pusher from 'pusher-js'
declare global {
  interface Window {
    Pusher: any;
    Echo: any;
  }
}
window.Pusher = Pusher

export default function () {
  window.Echo = new Echo({
    broadcaster: "pusher",   
    // wsHost:  import.meta.env.VITE_APP_HOST, 
    // wssPort: import.meta.env.VITE_PORT ?? 443,
    forceTLS: true,
   
    key:  import.meta.env.VITE_BROADCAST_APP_KEY,
    cluster: import.meta.env.VITE_BROADCAST_APP_CLUSTER,  

   
    authorizer: (channel: { name: string }, options: any) => {
      return {
        authorize: (socketId: string, callback: Function) => {
          axios
            .post("/broadcasting/auth", {
              socket_id: socketId,
              channel_name: channel.name,
            })
            .then((response) => {
              callback(false, response);
            })
            .catch((error) => {
              callback(true, error);
            });
        },
      };
    },
  });


}

@saifulbdDev
Copy link
Author

Screenshot_24
nuxt project subscription succeeded showing but vite error provite

@driesvints
Copy link
Member

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants