I can redirect the default Railway domain to the main domain that I have?

I want to set up a redirection for my default domain, for example, domain.up.railway.app redirect to domain.com.
7 Replies
Percy
Percy6mo ago
Project ID: N/A
Fragly
Fragly6mo ago
You could probably set that up in your code
if (req.host == "domain.up.railway.app") res.redirect("domain.com")
if (req.host == "domain.up.railway.app") res.redirect("domain.com")
ineedHelp😭
ineedHelp😭6mo ago
It didn't work, when I put domain.up.railway.ap the same domain continues to appear, it doesn't change.
Fragly
Fragly6mo ago
that would be an issue with your code
ineedHelp😭
ineedHelp😭6mo ago
My code: import express from 'express'; import logger from 'morgan'; const app = express(); const port = config.PORT app.use(express.json()); app.disable('x-powered-by') app.use(logger('dev')) app.use(express.static('client-microAngel')); app.use((req, res, next) => { if (req.hostname === "clinicamicropigmentacao.up.railway.app") { console.log("n deu mano.....",req.url); return res.redirect("https://clinicamicropigmentacao.com" + req.url); } next(); console.log("n deu mano.....",req.url); }); app.get('/', (req, res) => { res.sendFile(process.cwd() + '/client-microAngel/index.html'); }); app.listen(port, '0.0.0.0', () => { console.log(Servidor ouvindo na porta ${port}); });
Fragly
Fragly6mo ago
odd, I used the same middleware you used and it worked as expected for me make sure you don't have other middleware that could be rerouting or blocking requests from propagating to the middleware responsible for redirecting
ineedHelp😭
ineedHelp😭6mo ago
ok, i'll see