Open christianwerz opened 4 years ago
Ha, I was just about to submit a PR that did exactly this (plus offered the ability to have servers configured to forward by proxy rather than redirect). Wish I'd seen this PR first, would have saved myself some time! @typicode This goes to addressing my concerns in Issue https://github.com/typicode/hotel/issues/350.
Something minor review-like things I noticed when I rebased my forward-by-proxy code on top of this branch:
The router pattern '/:id/*' doesn't seem to actually match on urls without a trailing slash, iehttp://localhost:2000/foo
, so I think you need to have both patterns present.
The definition let target = item.target
in group.js's redirect method happens before item.target is set, which seems to be problematic when I run it locally. Additionally, path seems to convert the url to relative, rather than absolute, which I suspect is not desirable (and definitely doesn't work for proxying the request).
I took a stab at the appropriate fixes here.
Inspired by https://github.com/typicode/hotel/pull/16
This allows you to do http://localhost:2000/cheatsheets/XYZ.html and have it redirect to http://localhost:68192/XYZ.html.