Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Redirect From Backend To FrontEnd after Authentication

I Have My Backend (nodejs) running on another Port And My Frontend (React) Running On Another Port...So After After Sending Credentials To Backend And Authentication...How Can I Redirect To Front End ?

like image 770
Salman Kazi Avatar asked Dec 06 '25 04:12

Salman Kazi


2 Answers

res.writeHead(302, {
    Location: 'http://front-end.com:8888/some/path'
});
res.end();

If you specify the full url you can redirect to another port using NodeJS.

like image 61
sromeu Avatar answered Dec 07 '25 18:12

sromeu


You may use a web API (Express JS) in nodejs to build web api and frontend any plainJS or modren libaries that will send HTTP request to backend. It will help more.

like image 39
Hidayat Arghandabi Avatar answered Dec 07 '25 20:12

Hidayat Arghandabi