如何在跨域导航期间提供数据
我想知道在浏览器中页面之间的跨域导航期间提供数据的选项以及是否有任何共同的做法。
作为我现在面临的示例:
说我在https://pagea.com
时,当用户单击某些链接时,我想显示另一个页面https:// pageb.com
托管在另一个域上。因此,我想为b
提供一些其他信息,在加载过程中可以使用。从字面上看,它可以是a
具有:用户名,地址,主题等的任何数据...提供。
我知道的解决方案之一是将这些数据放入查询参数中,以便导航URL看起来像:https://pageb.com?username = ....... address=...Address=....。amp.amp; theme=。 。但是,如果有很多数据,则无法使用。
我知道的另一个解决方案是将数据临时存储在服务器上:a a
向服务器发表请求,服务器将数据存储在某个地方,并返回可用于获取数据的密钥。我导航到页面b
在查询参数中提供键 - https://pageb.com?key= {key}
和b
b 应该使用该密钥从服务器获取数据。对于我的例子来说,这似乎是一个可以的解决方案。
但是我想知道是否还有其他解决方案?当提供大量数据时,有什么共同的做法?
提前致谢!
I'd like to know what are the options for providing data during cross-domain navigation between pages in browser and if there's any common practice for that.
As an example of what I'm facing right now:
Say I'm on https://PageA.com
and when user clicks some link I want to show another page https://PageB.com
which is hosted on another domain. With that I want to provide some additional information for Page B
, which it can use during loading. It could be literally any data that Page A
has: user name, address, theme, whatever else... Let's just assume that there's a lot of data that Page A
can provide.
One of the solutions I know is to put this data into query parameters so navigation url would look something like: https://PageB.com?username=...&address=...&theme=...
It's OK to use when number of parameters is fixed and "small", I mean when url length don't reach the limit. However if there's a lot of data it can't be used.
Another solution that I know is to temporarily store data on server: Page A
makes POST request to the server, server stores data somewhere and returns a key that could be used to fetch that data. I navigate to Page B
providing key in a query parameters - https://PageB.com?key={key}
, and Page B
should fetch data from the server using that key. This seem to be an OK solution for my example.
However I'd like to know if there is any other solution to this? What are the common practices when there's a lot of data to be provided?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论