External redirection on express

Asked

Viewed 320 times

0

Galley,

How do I change this line of my code:

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

For 1 external redirect, for example redirect to

http://www.google.com
  • Will be res.redirect('http://www.google.com');? Inside the hustle you want me to redirect

  • Why do you want to tell the browser to ignore static files and use an external url? If you explain what you want to do I think you’ll get better help.

  • @Miguel this res in which place? when starting http?

  • Right-hand side of a route, see: http://stackoverflow.com/questions/28352871/in-express-how-do-i-redirect-a-user-to-external-url or http://stackoverflow.com/questions/6757061/route-client-to-external-site-in-node-js

  • @Sergio I will not use the static part of my app, I passed it to another domain and I will be just consuming the services, because I need to do several things friendly URL and etc.

  • @Miguel understood, then this line in my server.js that treats Static would cease to exist, correct?

  • I think this line can continue, just redirect wherever you want... on the route you want

  • Wouldn’t it be a case of using the <base>? If you are not going to the server to return a redirect and it is more time consuming.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.