英文:
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
-
查询参数:您可以使用URL中的查询参数在子域之间传递数据。例如,您可以在从第一个子域导航到第二个子域时,将数据附加到URL的一部分。
-
共享后端/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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论