Skip to content

allow appendNext to derive from another source #150

@travi

Description

@travi

my application has a somewhat unique configuration that isn't playng nice with the default behavior of appendNext in this plugin.

in order to direct all requests for text/html to a single route so that they can be routed by react-router, i have created a plugin that adds an onRequest handler to re-route all of these requests to a /html route.

then, in the /html route, i access request.raw.req.url to pass the original route to react-router.

the problem arrises when a redirect happens due to the lack of a session cookie. appendNext looks directly at request.url.path, so it is always /html in my case.

would it make sense to reference request.raw.req.url instead of request.url.path? the same value should be available from the raw request (in some variation, maybe not raw.req.url) to cover the common case, but would then also cover the .setUrl() case like mine as well.

if this isn't desirable, could an option be added to get the value in another way? maybe provide a callback that received the request object and expected the desired value to be returned?

for a little more context, i would have preferred to solve my original routing problem through content-negotiating config on my hapi routes, but since hapi does not support that, my current solution was a recommendation from the hapi team and seems like the next best option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions