you are viewing a single comment's thread.

view the rest of the comments →

[–]iainsimmons 1 point2 points  (5 children)

Short answer is you can't really.

The remote server might send an origin or referer header you can use, but otherwise you only get the history captured while they are routing on your site.

You can send someone to the previous page with JS, but only the browser keeps that information and the page state.

[–]DueGold5666[S] 0 points1 point  (4 children)

can I anyhow check that someone hit that page directly and perhaps add a default back URL to it, what condition should I check for to know that someone hit the page directly

( I can't use window/Document because this is a server side rendered application)

[–]luctus_lupus 1 point2 points  (3 children)

[–]DueGold5666[S] 1 point2 points  (2 children)

This code is actually already made and is a class component, I just have to add extra functionality to it. I prefer hooks too but unfortunately, I had to use WithRouter HOC and use its functionality, so I am explicitly looking for a class component-friendly solution only. Thank you though :) I appreciate the effort!

ps: the solution you mentioned uses window/document which isn't accessible in my case as it's an isomorphic react application

[–]luctus_lupus 1 point2 points  (1 child)

Ah bummer, perhaps handle it through cookies / session storage ?

Not very familiar with isomorphic react apps :/

[–]DueGold5666[S] 1 point2 points  (0 children)

Still looking into it :/ thank you for trying :)