简体   繁体   English

如何将具有 url 或路径名的自定义状态从前端发送到后端,以便在登录后将页面重定向到当前 url 以与 azuread 反应

[英]How to send custom state which has url or pathname from front end to backend for redirecting the page to current url after login in react with azuread

landing page need to be same as requested url after logging in .登陆页面需要与登录后请求的url相同。 So thought of using custom state in which url or pathname should be stored .所以想到使用自定义状态,其中应该存储 url 或 pathname 。 So how should i access the previous url , if i need to get it from frontend how can I get it without using props.history.push ?那么我应该如何访问以前的 url,如果我需要从前端获取它,我如何在不使用 props.history.push 的情况下获取它? Please suggest some ideas请提出一些想法

Please check if this can narrow down the issue:请检查这是否可以缩小问题的范围:

  1. Go to browser settings>developer tools>console and check mark the preserve log option.转到浏览器设置>开发人员工具>控制台并选中保留日志选项。

在此处输入图片说明

  1. Please check if navigateToLoginRequestUrl is set to true in userAgentApplication callback constructor.请检查在 userAgentApplication 回调构造函数中是否将navigateToLoginRequestUrl设置为true By default, msal tries to take you back to the loginStartPage after successful authentication.默认情况下,msal 会在成功验证后尝试将您带回 loginStartPage。 It can be disabled or set to false when not required.不需要时可以将其禁用或设置为 false。 See : AzureAD/msal for js (github.com)请参阅: 用于 js 的 AzureAD/msal (github.com)
  2. Please check if you can use callback path like this as stated in junnas blog and store a local redirect url session cache请检查您是否可以使用junnas 博客中所述的回调路径并存储本地重定向 url 会话缓存

References:参考:

  1. msal.js issures | msal.js 问题 | GitHub GitHub
  2. SO reference SO参考
  3. Redirect to Previous URL after Login with Auth Guard | 使用 Auth Guard 登录后重定向到上一个 URL | Jason Watmore's Blog Jason Watmore 的博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用React前端从URL获取参数并表达后端? - How to get params from url with React front end and express backend? 登录后重定向url(反应js) - Redirecting the url after login (react js) 使用 Puppeteer 从当前页面重定向到另一个页面后如何获取 URL? - How To Get The URL After Redirecting from Current Page To Another Using Puppeteer? 如何安全地将数据从后端发送到前端 - How to send data from backend to front end securely 如何将数据从 React 前端 Hooks 传递到 Express 后端 - How to pass data from React front end Hooks to Express backend 单独获取HTML当前页面名称,然后使用Jquery和Javascript从URL或路径名中获取“ .htm” - Get HTML Current Page name alone, followed by “.htm” from URL or Pathname using Jquery & Javascript Rails 5:获取当前 URL 并发送回后端 - Rails 5: Get current URL and send back to backend 如何发送GET值而不将用户重定向到该URL页面? - How to send GET values without redirecting user to that URL page? 如何在前端和后端之间持久化 Firebase Auth state? (Firebase 身份验证 + React + Express) - How to persist the Firebase Auth state between front-end and backend ? (Firebase Auth + React + Express) 无法将数组类型的变量从React.js前端发送到Django后端 - Cannot send an array-type variable from React.js front-end to Django backend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM