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

Server Side Event is Not Working #5855

Closed
poovarasanvasudevan opened this issue Dec 11, 2018 · 1 comment
Closed

Server Side Event is Not Working #5855

poovarasanvasudevan opened this issue Dec 11, 2018 · 1 comment

Comments

@poovarasanvasudevan
Copy link

Bug report

Server Side Event is Not Working

Describe the bug

i am using express-sse (https://www.npmjs.com/package/express-sse) for server side event server , i point to /stream as an endpoint to SSE

var SSE = require('express-sse');
var sse = new SSE(["array", "containing", "initial", "content", "(optional)"]);

nxt.prepare()
    .then(() => {
         app.get('/stream', sse.init);
   })

and in the client side

    componentDidMount() {
        this.source = new EventSource('/stream')
        this.source.onmessage = function(e) {
           console.log(e)
        }
    }

I able to Successully connected to (SSE) server by when i emit from server side, i am not able to get from client side

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:
Create blank nextjs project and install express and express-sse

in the server.js Create sse endpoint

var SSE = require('express-sse');
var sse = new SSE(["array", "containing", "initial", "content", "(optional)"]);

nxt.prepare()
    .then(() => {
         app.get('/stream', sse.init);
   })

and in index.js (Client)

    componentDidMount() {
        this.source = new EventSource('/stream')
        this.source.onmessage = function(e) {
           console.log(e)
        }
    }

Expected behavior

i added console.log it was not printing, i am hitting from the server

System information

  • OS: Windows
  • Chrome, Firefox
  • Version of Next.js: 7.0.2
@timneutkens
Copy link
Member

This does not relate to Next.js / Is not a bug in Next.js.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants