node.js - Any simple way to create link in ExpressJS? -
sometimes need create absolute link in web site.
like http://example.com/xxxx/xxxx?foo=bar
not /xxxx/xxxx?foo=bar
here has anyway create simple helper express manually?
just like:
app.locals.url = function ( pathto, opts ) { // somethings here. }
i think may need ssl check, host , route check or somethings.
you can create full url :
var url = req.protocol + '://' + req.get('host') + req.originalurl;
them can redirect url
Comments
Post a Comment