Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving ember app from IIS resulting in UnrecognizedURLError

I am trying to serve an ember app from IIS.

I created a new app using ember new my-app and then ran ember build --environment production. This generated the files in the dist directory as expected.

On the IIS side, I added a new website on the server and mapped the dist folder from the last step.

Now, when I navigate to localhost/index.html I get a blank page.

I checked the source of the page and the js files are being served correctly as expected. This would mean that it's the templates that are not being retrieved correctly. In the chrome inspector console there is an exception which says Uncaught: UnrecognizedURLError: /index.html. The ember inspector says 'Ember application not detected!'.

I've tried the solutions mentioned here, but none has worked for me.

Has anyone else experienced this problem/know how to fix this?

like image 710
reggaemahn Avatar asked Oct 09 '15 15:10

reggaemahn


1 Answers

Ember Router uses location: history by default. This means, it assumes that /index.html is your route. But obviously it's not defined so the router throws UnrecognizedURLError.

There are several solutions for your problem:

  1. Set locationType: 'hash' in config/environment.js of your ember application. This will force Ember router to use # in url for routing and in your case this would be like localhost/index.html#your/route.

  2. Configure your IIS instance to handle index.html as a default document. To do this, open your server config and make sure it has the key:

enter image description here

  1. Change ember build config to produce index.aspx instead of index.html. You can read about it here.
like image 88
Artur Smirnov Avatar answered Oct 31 '22 19:10

Artur Smirnov