karma
karma copied to clipboard
failed to proxy simple files
I am having trouble configuring Karma to proxy requests to particular files on the file system. IIRC, this used to work a few years ago but some Karma upgrade probably broke these. I have enabled debug level logging but it does not say much in the output.
This happens for a variety of files but here is my most recent issue:
files: [
{
pattern: 'node_modules/msw/lib/mockServiceWorker.js',
included: false,
served: true,
},
],
proxies: {
'/mockServiceWorker.js': '/base/node_modules/msw/lib/mockServiceWorker.js',
},
Loading up http://localhost:9876/base/node_modules/msw/lib/mockServiceWorker.js
works great. But the actual proxy http://localhost:9876/mockServiceWorker.js
does not work and gives the following output (with debug level):
06 04 2023 18:18:14.605:DEBUG [middleware:source-files]: Requesting /mockServiceWorker.js
06 04 2023 18:18:14.605:DEBUG [middleware:source-files]: Fetching /mockServiceWorker.js
06 04 2023 18:18:14.605:DEBUG [proxy]: proxying request - /mockServiceWorker.js to localhost:9876
06 04 2023 18:18:14.611:WARN [proxy]: failed to proxy /base/node_modules/msw/lib/mockServiceWorker.js (connect ECONNREFUSED ::1:9876)
Is there a specific proxy configuration to use for files?