跨同一域但使用不同端口的页面上的本地存储 [英] Local storage across pages on same domain but using different ports

查看:153
本文介绍了跨同一域但使用不同端口的页面上的本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在同一域的各个页面上使用本地存储,但是由于某些原因,如果Firefox使用不同的端口,则会在页面之间创建同一存储数据的多个实例.因此,如果我为www.example.com:80设置了一些在访问www.example.com:8000时不会持久的内容,它将创建相同数据的全新冗余条目.我该如何纠正并使其使用同一条目?

I'm trying to use local storage across various pages on the same domain, but for some reason Firefox is creating multiple instances of the same storage data across pages if they are using different ports. So if I set something for www.example.com:80 that won't persist when going to www.example.com:8000, it will create an entirely new redundant entry of the same data. How can I rectify this and get it to use the same entry?

推荐答案

端口必须相同,源规则才能正常工作.解决此问题的唯一方法是服务器端代理.

Ports must be the same for origin rules to work. The only way around this is a server-side proxy.

原产地定义:

Definition of an origin:

如果协议,端口(如果一个是 指定),并且两个页面的主机都相同.

Two pages have the same origin if the protocol, port (if one is specified), and host are the same for both pages.

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Same_origin_policy_for_JavaScript

这篇关于跨同一域但使用不同端口的页面上的本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆