Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

Socket Problem Node

aboutabot
aboutabot

Hey, I just learned SocketIO and Express on a tutorial and I don't really know it that well, and I tried to send a message from one client to the server to the other client in a room. This only works if I run the repl from the server, and then reload both the https://server.aboutabot.repl.co page and the replit page I coded it on.
help?

1 year ago

Comments

TopNew
1
Geocube101
Geocube101

You may have to serve the html file containing your client side code

app.get('/', function(req, res) { res.sendFile(__dirname + "/public/index.html"); });
1 year ago
1
aboutabot
aboutabot

@Geocube101
I put it in now, but it no longer asks me for my room name or my name in the alert prompt

1 year ago
1
Geocube101
Geocube101

@aboutabot
there is an issue with the <script> tag as the html page cannot locate the js files.
Try using:

<script src="script.js"></script>

...to load your script.js file

1 year ago
1
aboutabot
aboutabot

@Geocube101
Ok, now I changed that, but the alert prompt still doesn't come.

1 year ago
1
Geocube101
Geocube101

@aboutabot
Ok, I had another look at my node.js repls. The script tag needs the full path to your file so try:

<script src="/public/script.js"></script>
1 year ago