如何使用 ChromeApp 连接到 node.js 服务器?

How to use the ChromeApp to connect to a node.js server?

我有一个 Node.js 服务器,我想知道如何才能让 ChromeApp 与它一起工作。我尝试在运行时放置“http://localhost:3000”(服务器地址):

chrome.app.runtime.onLaunched.addListener(function () {
   chrome.app.window.create('http://localhost:3000');
});

但它甚至没有启动。有人知道我能做什么吗? 谢谢

您无法使用 chrome.app.window.create 启动外部 URL。事实上,如果你检查 chrome.runtime.lastError 属性 你会看到以下错误:

The URL used for window creation must be local for security reasons.

我建议您考虑使用 <webview> 标签,因为它更适合您的用例。