首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何告诉流体FrameWork锡兰,以允许跨原点的请求从特定的网址?

我如何告诉流体FrameWork锡兰,以允许跨原点的请求从特定的网址?
EN

Stack Overflow用户
提问于 2021-08-05 22:06:08
回答 1查看 181关注 0票数 1

我希望使用Tinyl定义/ Framework来实现在不同机器上的客户端之间的通信。为了应用程序特定的目的,我让我的应用服务器运行在https上(在https://<domain1>.ngrok.io/)。然后,我从不同的https (在https://<domain2>.ngrok.io/)中得到了美味的服务。下面是如何实例化我的流体客户端和连接(来自https://github.com/microsoft/FluidHelloWorld的代码):

代码语言:javascript
复制
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/):的域)。

代码语言:javascript
复制
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/)应该允许?

EN

回答 1

Stack Overflow用户

发布于 2021-08-17 11:54:53

这是因为在ngrok源文件页面中没有访问控制-允许-原产地标题.

因为您只是为了本地测试而运行这个程序,所以您可以使用一个插件来向每个请求添加访问控制-允许-原产地头。这个Chrome扩展为你做的,虽然我肯定还有其他的。

https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68674011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档