gpt4 book ai didi

javascript - 从 IIS 提供 ember 应用程序导致 UnrecognizedURLError

转载 作者:数据小太阳 更新时间:2023-10-29 04:45:51 30 4
gpt4 key购买 nike

我正在尝试从 IIS 提供一个 ember 应用程序。

我使用 ember new my-app 创建了一个新应用,然后运行 ​​ember build --environment production。这会按预期在 dist 目录中生成文件。

在 IIS 端,我在服务器上添加了一个新网站,并映射了上一步中的 dist 文件夹。

现在,当我导航到 localhost/index.html 时,我得到一个空白页面。

我检查了页面的来源,并且 js 文件按预期正确提供。这意味着它是没有被正确检索的模板。在 chrome 检查器控制台中,有一个异常显示 Uncaught: UnrecognizedURLError:/index.html。 ember 检查员说“未检测到 Ember 应用程序!”。

我已经尝试了提到的解决方案 here ,但没有一个对我有用。

有没有其他人遇到过这个问题/知道如何解决这个问题?

最佳答案

Ember Router 默认使用 location: history。这意味着,它假定 /index.html 是您的路线。但显然它没有定义,所以路由器抛出 UnrecognizedURLError

您的问题有多种解决方案:

  1. 在您的 ember 应用程序的 config/environment.js 中设置 locationType: 'hash'。这将强制 Ember 路由器在 url 中使用 # 进行路由,在您的情况下,这类似于 localhost/index.html#your/route

    <
  2. 配置您的 IIS 实例以将 index.html 作为默认文档处理。为此,请打开您的服务器配置并确保它具有 key :

enter image description here

  1. 更改 ember 构建配置以生成 index.aspx 而不是 index.html。你可以阅读它here .

关于javascript - 从 IIS 提供 ember 应用程序导致 UnrecognizedURLError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33042453/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com