我希望使用Tinyl定义/ Framework来实现在不同机器上的客户端之间的通信。为了应用程序特定的目的,我让我的应用服务器运行在https上(在https://<domain1>.ngrok.io/)。然后,我从不同的https (在https://<domain2>.ngrok.io/)中得到了美味的服务。下面是如何实例化我的流体客户端和连接(来自https://github.com/microsoft/FluidHelloWorld的代码):
import { ContainerSchema, SharedMap } from "@fluid-experimental/fluid-framework";
import { FrsClient, FrsConnectionConfig, FrsContainerConfig, InsecureTokenProvider } from "@fluid-experimental/frs-client";
import { getContainerId } from "./utils";
const { id, isNew } = getContainerId();
const localConfig: FrsConnectionConfig = {
tenantId: "local",
tokenProvider: new InsecureTokenProvider("anyValue", { id: "userId" }),
orderer: "https://<domain2>.ngrok.io",
storage: "https://<domain2>.ngrok.io"
};
const client = new FrsClient(localConfig);
const containerConfig: FrsContainerConfig = { id };
const containerSchema: ContainerSchema = {
name: "hello-world-demo-container",
initialObjects: { data: SharedMap }
};
const { fluidContainer } = isNew
? await client.createContainer(containerConfig, containerSchema)
: await client.getContainer(containerConfig, containerSchema);
...然而,当我运行我的应用程序时,当我试图连接到Tinylicious时,我会得到这个https://<domain1>.ngrok.io/)跨源错误,因为我的应用程序(在(https://<domain2>.ngrok.io/):上有一个不同于Tinylury(https://<domain2>.ngrok.io/):的域)。
Access to XMLHttpRequest at 'https://<domain2>.ngrok.io/documents/local' from origin 'https://<domain1>.ngrok.io' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.是否有一种方法可以实例化Tinyl定义或其他流体服务,并告诉它的起源(即,https://<domain1>.ngrok.io/)应该允许?
发布于 2021-08-17 11:54:53
这是因为在ngrok源文件页面中没有访问控制-允许-原产地标题.
因为您只是为了本地测试而运行这个程序,所以您可以使用一个插件来向每个请求添加访问控制-允许-原产地头。这个Chrome扩展为你做的,虽然我肯定还有其他的。
https://stackoverflow.com/questions/68674011
复制相似问题