a year ago
require('dotenv').config()
const express = require('express');
const cors = require('cors');
const http = require('http');
const userRouter = require('./router/router')
const socketIo = require('socket.io');
const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
cors: {
origin: '*'
}
});
app.use(cors());
app.use(express.json())
app.use(express.urlencoded({ extended: false }));
app.use('/', userRouter);
app.set('trust proxy', true);
const port = process.env.PORT || 4000;
server.listen(port, () => {
console.log(Express server listening on port ${port});
});
when i deploy the code why only wss service that available in railway given url? why https can't be accessed? ( plain http/ws still works)
0 Replies
do I get this right:
when you are running on a local machine (no TLS), both ws and http can be accessed from the same port (4000 in case of the code above)
but when deployed to railway somehow http stops working?
how does this not availability manifest itself?
a 404 error, connection reset or a railway error page saying that "app failed to respond"?
if so, it is likely that during deploy the static assets that were meant to be served by the app were not included for some reason
ok the trigger of https routes already found in console.log(), idk what's going on but i change the ver into legacy and then change the version into v2 again
it looks like this
const express = require('express')
const router = express.Router()
const userController = require('../controller/userController')
const Auth = require('../middleware/auth')
router.post('/signup',userController.signup)
router.post('/login',userController.login)
router.post('/logout',Auth.verifyToken,userController.logout)
router.post('/verify',Auth.verifyToken,userController.verify)
router.post('/otp',userController.otp)
router.post('/ubah',userController.ubah)
router.post('/hapus',userController.hapus)
router.post('/lupa',userController.lupa)
router.get('/getcategory',userController.getcategory)
router.get('/getproduct',userController.getproduct)
router.post('/insertpesan',userController.insertpesan)
router.post('/getpesan',userController.getpesan)
module.exports = router
{
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5432
}