scully: cli: support catch all routes (i.e. to a custom 404 page)

Steps to Reproduce

  1. ng add @scullyio/init
  2. npm i --save-dev fs-extra
  3. ng build
  4. npm run scully

Error

Cleaned up /Users/splaktar/Git/.../dist/static/ folder.
started servers in background
Invalid content-type.
Expected application/json but received text/html; charset=UTF-8
<repeated about 30 times>
Invalid content-type.
Expected application/json but received text/html; charset=UTF-8
Could not connect to server

The debugger indicates that this is caused by the following line https://github.com/scullyio/scully/blob/eba6fba6a5df182137fdb7b434893162bc962dc3/scully/utils/waitForServerToBeAvailable.ts#L13

That URL (http://localhost:1864/_pong) seems to be returning my Angular app (in a broken state) rather than some JSON content.

Root Cause

A route like {path: '**', component: PageNotFoundComponent} breaks the ability to run Scully. Removing it works around the problem, but breaks the app’s custom 404 page.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (14 by maintainers)

Most upvoted comments

@Splaktar Yes, a partial fix might be in a bit earlier, but that one closed it completely.

@SanderElias Are you able to share your PR? I’d like to test it if I can.

I’m pretty sure just need to move the _pong and killMe routes above the routes loop here: https://github.com/scullyio/scully/blob/596d09296ea78d100d5093c2af9683a79483ed5f/scully/utils/staticServer.ts#L37

I haven’t yet been able to build scully for dev so I can’t test that.

Edit: PR submitted. Tested locally.

That worked (after killing the node process that was still around from the previous run)!

Cleaned up /Users/splaktar/Git/.../dist/static/ folder.
started servers in background
servers available
Finding all routes in application.
Pull in data to create additional routes.
Route list created in files:
      src/assets/scully-routes.json
      /Users/splaktar/Git/.../dist/static/assets/scully-routes.json
Route "" rendered into file: "/Users/splaktar/Git/.../dist/static/index.html"
Route list created in files:
      src/assets/scully-routes.json
      /Users/splaktar/Git/.../dist/static/assets/scully-routes.json

Generating took 9.32 seconds for 1 pages:
  That is 0.11 pages per second,
  or 9327 milliseconds for each page.

Try removing the ** catch all…

I see the same issue… nothing special in my test app. Generated a new ng8 app using the cli, ng updated to ng9-rc, then ng added scully.

Running npm run scully throws the Invalid content-type errors.

I see lots of js files in dist/static, however, all js requests on http://localhost:1864/ return contents of index.html.