0

My angular app contains percent-encoded routes. Ex. /Page%201

When I run my angular app with ng serve everything works fine.

But when I start the Scully static server and visit "http://localhost:1668/Page%201", the browser shows

Cannot GET /Page%201

I looked into my ./dist/static/assets/scully-routes.json and I can see the ,{"route":"/Page%201"}.

This behavior doesn't happen on routes without space.

Ex. http://localhost:1668/Page2 works just fine.

domrac
  • 61
  • 1
  • 6

1 Answers1

1

The scully static server serves files matching the unescaped URI. In your case, when you enter http://localhost:1668/Page%201, the server will try to find a folder named /Page 1 which doesn't exist.

Solution 1: Frontend Side

After scully has generated the dist/static folder, rename all escaped name to their unescaped name. Ex. /foo%20bar/ to /foo bar/.

Solution 2: Server Side

Using nginx, I added this line to my nginx.conf:

      try_files $uri $uri/ $request_uri/index.html /index.html;

$uri is escaped and $request_uri is unescaped.

It will try /foo bar, then /foo bar/ and then /foo%20bar/index.html which will find a match.

Advice

If you can, just use ASCII in your urls.

domrac
  • 61
  • 1
  • 6