Is there any way to pass data from one sub domain to another subdomain opens in 2 different tabs in react

huangapple go评论72阅读模式
英文:

Is there any way to pass data from one sub domain to another subdomain opens in 2 different tabs in react

问题

我尝试过使用本地存储、会话存储和Cookie,但无法传递数据。是否有办法从第一个子域传递数据到第二个子域?我的示例使用React js。

英文:

I have 1st sub-domain eg. a.xyz.com and trying to pass data to 2nd subdomain eg. b.xyz.com which is under domain eg. xyz.com..

I have tried using local storage , session storage and cookies, but not able to pass.
Is there any solution to pass data from first sub-domain to second sub-domain
my example uses React js

答案1

得分: 1

  1. 查询参数:您可以使用URL中的查询参数在子域之间传递数据。例如,您可以在从第一个子域导航到第二个子域时,将数据附加到URL的一部分。

  2. 共享后端/API:如果第一个和第二个子域共享一个公共的后端或API,您可以将数据存储在服务器端,并通过向服务器发出请求,在第二个子域中检索它。

英文:

You can try one of the following way to pass the data:

1. Query Parameters: You can pass data between subdomains using query parameters in the URL. For example, you can append the data as part of the URL when navigating from the first subdomain to the second subdomain.

2. Shared Backend/API: If the first and second subdomains share a common backend or API, you can store the data on the server-side and retrieve it in the second subdomain by making a request to the server.

huangapple
  • 本文由 发表于 2023年7月17日 17:03:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76702914.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定