Microsoft Teams 选项卡 http/https 未发送请求

Microsoft Teams tab http/https does not send request

我想创建一个 Microsoft Teams 选项卡作为 Web 应用程序。我已经完成了初始设置 运行。 (使用 Yo Teams)现在我想向 Azure Functions 发送一个 http(s) 请求。所以我添加了一个 post 中间件 函数到我的 server.ts,它应该调用函数。

    express.post("/createteamswiki", (req, res) => {
        https.request("my.function.url", { method : "POST" }, () => {
        });
        res.status(200);
        res.json("Oki");
    }); 

在我的WikiConfig.ts中,我更改了保存方法来发送请求。我尝试使用 vanilla-js 和模块:httphttps。使用 vanilla-js,请求被发送,但它在 Chrome 开发工具中被标记为 ERR_FAILED。图书馆根本不发送任何东西。所以成功回调永远不会被调用,因此 saveEvent.notifySuccess(); 也不会被调用。所以配置window留下来报错

    public async componentWillMount() {
            this.updateTheme(this.getQueryVariable("theme"));
    
            if (await this.inTeams()) {
                microsoftTeams.initialize();
    
                microsoftTeams.getContext((context: microsoftTeams.Context) => {
                    this.setState({
                        value: context.entityId
                    });
                    this.updateTheme(context.theme);
                    microsoftTeams.settings.setValidityState(true);
                    microsoftTeams.appInitialization.notifySuccess();
                });
    
                microsoftTeams.settings.registerOnSaveHandler((saveEvent: microsoftTeams.settings.SaveEvent) => {
                    // Calculate host dynamically to enable local debugging
                    const host = "https://" + window.location.host;
                    microsoftTeams.settings.setSettings({
                        contentUrl: host + "/sharepointWikiTab/?name={loginHint}&tenant={tid}&group={groupId}&theme={theme}",
                        websiteUrl: host + "/sharepointWikiTab/?name={loginHint}&tenant={tid}&group={groupId}&theme={theme}",
                        suggestedDisplayName: "Sharepoint Wiki",
                        removeUrl: host + "/sharepointWikiTab/remove.html?theme={theme}",
                        entityId: this.state.value
                    });
                    microsoftTeams.getContext((context: microsoftTeams.Context) => {
                        this.setState({
                            value: context.teamSiteUrl || ""
                        });
                        https.request("https://" + window.location.host + "/createteamswiki?code=gM6t7bov41tkw1ZTxGZUasY1WQH7UgrONp4OyoVzaYaFtFBTBwZcRQ==&team=" + context.teamSiteUrl, (res) => {
                            this.setState({
                                value: "Awesome it works..."
                            });
                            saveEvent.notifySuccess();
                        });
                    });
                    // saveEvent.notifySuccess();
                });
            } else {
            }
        }

我找不到它为什么会这样的任何原因,因为请求调用了 node.js 服务器,它成功地提供了 http 文件。

我认为这是由于跨源请求造成的。您能否检查您的请求 header 并查看 CORS 是否已启用,并检查 url 是否已添加到清单

的 validDomain[] 数组中