'script source not found, in node.js when trying https connection

im trying to reference socket.io in my login.html but it gives following error:

GET https://localhost:3000/socket.io.js net::ERR_ABORTED 404 (Not Found)

i think its because this code line in my login.html :

<script src='/client-dist/socket.io.js'></script>

i was trying other reference the script in other ways, but those doesnt work. it worked when my server.js was a http connection, but now i need a https connection. its also dont possible to reference oder javascript refrences.

login.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login</title>
    <link rel="stylesheet" href="/style.css">
</head>
<body>
   
<section>

  <h1>Login</h1>

<p>
  username:<input id="username">
  <br>
  password:<input id="password">
  <br>
  
</p>

<p>
  
  <button onclick="window.location.href='/register'">Create Account</button>
</p>

<button id="submitButtonLogin" onclick="onClick()">submit</button>
  

    </section>

    <script src='/client-dist/socket.io.js'></script>
    

</body>
</html>

server.js:

const express= require('express')
const app= express();
//const path= require('path')
const https= require('https')
const io=require('socket.io')(https,{maxHttpsBufferSize:1e8})
const fs=require('fs')




const sslServer =https.createServer({
    key: fs.readFileSync('cert/key.pem'),
    cert: fs.readFileSync('cert/cert.pem')
},app)


const PORT=process.env.PORT || 3000



sslServer.listen(PORT, ()=>{
    console.log(`listening to port ${PORT}`)
});sslServer.setTimeout(0)


app.get('/test', (req,res)=>{
    res.sendStatus(200);
})

app.use(express.static(__dirname + '/public'))

app.use(require('./routes/posts'));

app.use(require('./routes/users'));

app.get('/',(req,res)=>{
    res.sendFile(__dirname + '/login_register/login.html')
})


app.get('/register',(req,res)=>{
    res.sendFile(__dirname + '/login_register/register.html')
})

app.get('/chatroom',(req,res)=>{
    res.sendFile(__dirname + '/index.html')
})

my hierarchy:

chatapplication
-cert
    cert.pem
    csr.pem
    key.pem
-login_register
    login.html
    register.html
-model
    user.js
-node_modules
    (included when setup) 
-public
    client.js
    style.css
-routes
    users.js
database.js
index.html
package-lock.json
package.json
secret.json
server.js


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source