Regarding PWA redirect when reopen application
Hello I am getting one issue for my PWA
I install PWA and open as url like {domainname}/test-result, and close it. But after that, when I tried to reopen application, it redirects to homepage instead of test-result page.
Is there any solution for this? Thank you
That's by design of PWA. It gives user experience that people usually expect like an native app. If you want to show user the page where they left last time, you have to implement yourself using local storage or index db or other methods to redirect user.
What you could do is store in a cookie (make sure the cookie is not a Session cookie) the current path each time a user navigate in your app. Then, add a getServerSideProps function in the test-result page and you can redirect the user to the path store in the context.req.cookies.path like so :
export const getServerSideProps: GetServerSideProps = async (context) => {
// Get the cookies of the incoming req
const cookies = context.req.cookies;
return {
redirect: {
destination: cookies.path ,
permanent: false,
},
};
};
You can read this topic to learn more about redirection