Skip to content

Instantly share code, notes, and snippets.

@nvcexploder
Created August 7, 2014 01:33
Show Gist options
  • Save nvcexploder/299886835c3f5aa6e157 to your computer and use it in GitHub Desktop.
Save nvcexploder/299886835c3f5aa6e157 to your computer and use it in GitHub Desktop.
Change URL in a hapi onRequest ext point.
// wherever you're setting up your server, this was within a register method for a plugin:
plugin.select('api').ext('onRequest', internals.onRequest);
//somewhere else in that file or whatever
var onRequest = function (request, next) {
request.setUrl(exports.rewriteUrl(request.raw.req.url));
next();
};
var rewriteUrl = function (requestUrl) {
/**
* magic to change request url
*/
return requestUrl;
};
@sinallcom
Copy link

For version 16:
Line 10:
return next.continue();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment