Replies: 3 comments 1 reply
-
Hi @ehenighan . We recently had a similar discussion internally, some engineers similarly requested the idea to support navigation actions with a (Note that in terms of confidential information, I don't think there's much of a security benefit of a I think the main hangup I have for supporting Some options we're considering:
I think option 2 is a cleaner, but it means the client would need to enforce that a I'm curious to understand more about the solution you're proposing for a post-navigate behavior, I'm not sure I fully get it. Could you share an example snippet of the XML markup and requests to demonstrate how it would work? |
Beta Was this translation helpful? Give feedback.
-
Hiya, Yeah, similar sorts of worries as I had really. So my two rough ideas, let's say we're talking about a logout action, and for [reasons] it has to be a POST. The server knows that the logout action must always cause a navigator reset on the client, so:
The behaviour handler for that would do a document load rather than an element load, but with the form body extracted from the parent/target form (did this for event-driven declarative form validation, that bit is fairly simple) and sent up as required (not needed for the logout example unless you need a CSRF token), expect only a I couldn't implement that last step because I couldn't find a way to bully the custom behaviour framework into letting me access the navigator object in the root props. So that would be one way to make that behaviour declarative, but I actually think there's a more general thing that would possibly be better:
So really if the app receives a navigator document instead of the fragment element it's expecting, I want it to just drop everything and navigate because the server says so - potentially behind a 'No, I Really Mean It' custom response header for backwards compatibility. That would mean that the logout POST case is just like every other - try it, server responds with 302, This would also work really nicely for logging in as well - and in particular it would be a big bonus for the confidential-client OAuth2 flow I've just finished hooking in because there's just too much redirecting in there already, so if the server could even cut out some redirects and return navigator responses directly it would make the flow a lot more responsive. Does that make a bit more sense? Don't have a code example conveniently to hand, I'm afraid. |
Beta Was this translation helpful? Give feedback.
-
Hi @adamstep, Think I've got a fairly easy solution to this for the server-side session expiry case:
The above is working cleanly for my most important needs (server-side session expiry) with about ten lines of code in total across the back end and native app. However, in theory I think you could do something more advanced/sneaky to read an arbitrary navigation response from the body and use it directly, something like:
It's a bit of a Rube Goldberg event chain and I haven't experimented with it, but it might be a viable way to auto-navigate from redirected server responses without more network overhead, and flexibly based on the contents of the server response. There might be some restrictions in the API which make it impossible though - can you do a A slight tweak to the above would be to have some special URL for this case, such as
This might be simpler to implement, and avoids messy DOM manipulation and a few layers of Rube Goldberg event firing. |
Beta Was this translation helpful? Give feedback.
-
Currently you can include form data in a GET as part of a navigation action, but you can't POST. If you do it with a GET the (potentially confidential) form data goes in the POST body. This means that in order to navigate on form POST success, you have to return a fragment with an on-load trigger to do the navigation.
I understand why you wouldn't want the routing to include anything other than the URL, but it's 90% possible to do this with a custom 'post-navigate' behaviour where you pull the form data out from the relevant form and submit it yourself through whatever
fetch
wrapper you passed in originally - if the server returns/redirects to a navigator, you can parse the document out directly using a clone of the parser object. However, you can't then trigger the navigation just by calling the updateRoot function with the new document, sadly.What would be really helpful is if there was a way to hook into the navigator from a custom behaviour directly and possibly even feed it a navigation document retrieved via a side channel - then creating a custom 'post-navigate' behaviour would be pretty easy and you could one-shot navigate on form submission instead of having to do the ungainly double-bounce.
Alternatively, any ideas about graceful redirect handling when the server side decides to issue a redirect - e.g. if the session is expired from the server? If you're caught on a form submission when that happens, it doesn't deal with the response very nicely. In my head it would be nice if the client could watch for e.g. something like a specialist header from the server to indicate it's a deliberate forced re-navigation, and then fire a navigate event to reload the screen stack instead of whatever it was aiming for. I'm sure that would cause a whole host of problems elsewhere though.
Beta Was this translation helpful? Give feedback.
All reactions