0

I have socket.io working locally. http://localhost:3000 is URL for Node.js backend and http://localhost:4200 URL for frontend Angular.

But it does not work when I deploy the app.

Folder structure:

parent-folder-name

 -backend folder

 -frontend files

All files of Angular located directly in the parent folder.

URLs:

http://mydomainnameexample.com/parent-folder-name/backend http://mydomainnameexample.com/parent-folder-name/ (frontend)

Code:

Client: this.socket = io('http://mydomainnameexample.com/parent-folder-name/');

Server side:

const http = require('http').Server(app);
const io = require('socket.io')(http);
io.sockets.on('connection', function(socket) {
  console.log('A client is connected!');

  socket.on('index', () => {
    console.log('socketData: ');
    testController.index(socket);
  });
});

I do have 404 in the console for this URL: http://mydomainnameexample.com/parent-folder-name/backend/?EIO=3&transport=polling&t=MQnDIEb

1 Answer 1

3

on the server side (Node.js) I added the path:

const io = require('socket.io')(http, {path: 'parent-folder-name/backend/socket.io'})`

And Client side:

this.socket = io('http://mydomainnameexample.com', { path: 'parent-folder-name/backend/socket.io' });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.