stijn.aerts
stijn.aerts

Reputation: 6206

Deploy ember gives UnrecognizedURLError

I compile my app for production mode with this command:

sudo ember build --environment=production

Then I copy the contents of the dist map into a map in filezilla.

When I go to subdomain.domain.eu/myRoute/44444, I get:

Uncaught UnrecognizedURLError

When I go to subdomain.domain.eu/index.html, the app loads but I need the 44444 from the urlin my app as a param.

How does this come and what is the solution?

My .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.html#$1 [L]

Building for development and production produces the same results. The current error I'm getting is 500 internal server error.

Upvotes: 1

Views: 522

Answers (1)

Fryie
Fryie

Reputation: 146

Since you're (very probably, unless you're using an old Ember version or explicitly enabled this) not using hash-based URLs, your rewrite rule should probably look like:

RewriteRule ^(.*)$ /index.html [PT,QSA]

The PT is needed to not change the URL and the QSA keeps any appended query strings around. Apparently, PT is apparently the default anyway for .htaccess files but it cannot hurt to make that explicit.

The reasoning is that you want Apache to not care about your URL and serve the index.html for everything. But since Ember needs the original URL to recognise what route it should serve, the URL needs to be unchanged as far as the client is concerned.

Upvotes: 2

Related Questions