export default new Router()
.prerender(getPrerenderRequests)
.match('/api/:path*', API_CACHE_HANDLER)
.match('/category/:name', SSR_CACHE_HANDLER)
.match('/product/:name', SSR_CACHE_HANDLER)
.match('/service-worker.js', ({ serviceWorker }) => {
serviceWorker('dist/service-worker.js')
})
// Send requests to static assets in the build output folder `dist`
.static('dist')
// Send everything else to the App Shell
.fallback(({ appShell }) => {
appShell('dist/index.html')
})
I have noticed the Prefetcher
makes a request to /__xdn__/cache-manifest.js
and it is failing with a 500 with the following response:
HTTP/1.1 500 Internal Server Error
X-Powered-By: Express
content-type: application/json
x-request-id: 4a598003-64e2-41a5-a4bb-ecb4079905f3
Date: Mon, 14 Dec 2020 18:38:41 GMT
Connection: keep-alive
Transfer-Encoding: chunked
{"message":"An error occured while running route /__xdn__/cache-manifest.js: appShell is not a function","stack":"TypeError: appShell is not a function\n at Route.handler (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:12492:3)\n at Function.__webpack_modules__../node_modules/@xdn/core/router/CacheManifest.js.CacheManifest.fromRouter (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:4651:23)\n at /Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:8515:92\n at ResponseWriter.<anonymous> (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:6533:46)\n at step (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:5517:23)\n at Object.next (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:5498:53)\n at /Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:5492:71\n at new Promise (<anonymous>)\n at __webpack_modules__../node_modules/@xdn/core/router/ResponseWriter.js.__awaiter (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:5488:12)\n at ResponseWriter.createResponseAction (/Users/tristanlee/Projects/xdn-org/xdn-examples/xdn-vue-example/.xdn/lambda/routes.js:6528:64)","url":"/__xdn__/cache-manifest.js","route":{"handler":"function (_a) {\n var cache = _a.cache, setResponseHeader = _a.setResponseHeader, send = _a.send, allowCors = _a.allowCors;\n cache({\n edge: {\n maxAgeSeconds: 60 * 60 * 24 * 365,\n },\n browser: {\n maxAgeSeconds: 60 * 60,\n },\n });\n setResponseHeader('content-type', 'text/javascript');\n allowCors();\n send(function () { return \"self.__XDN_CACHE_MANIFEST__=\" + CacheManifest_1.default.fromRouter(router).toJSON(); });\n }","criteria":{"path":"/__xdn__/cache-manifest.js"}}}
Status: 500, Connect: 0.000895, TTFB: 0.019666, Total: 0.019713%
After a bit of debugging, it is being handled by .fallback(...)
which I don’t believe it should be reaching, but also doesn’t have all of the same properties available that ResponseWriter
typically would as appShell
is not defined. If I comment out my fallback route, then the route is handled successfully.