Log http traffic in ADF devServer?

cancel
Showing results for 
Search instead for 
Did you mean: 
queshaw
Member II

Log http traffic in ADF devServer?

My CORS configuration doesn't seem to work. Is there a way to log traffic? I have this:

devServer.proxy."/ecm".logLevel: 'debug'

devServer.proxy."/ecm".error: function(err, req, res) {

console.log(err)

}

devServer.proxy."/ecm".onProxyReq: function (proxyReq, req, res) {

console.log('RAW Request from the target', JSON.stringify(proxyReq.headers, true, 2));

}

devServer.proxy."/ecm".onProxyRes: function (proxyRes, req, res) {

console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
const header = proxyRes.headers['www-authenticate'];
if (header && header.startsWith('Basic')) {
  proxyRes.headers['www-authenticate'] = 'x' + header;
}

}

and in wsrv-config.js:

"proxy": {
"/ecm/{p*}": {
"options": {
"uri": "http://0.0.0.0:8082/{p}",
"verbose": true
}
},

But, no messages appear on the console. 

8082 is alfresco community 6.x (for testing), but nothing appears in the access log

6 Replies
dvuika
Alfresco Employee

Re: Log http traffic in ADF devServer?

What version of ADF are you using? The 1.9 and 2.0 are using Angular CLI and its webpack dev server.

queshaw
Member II

Re: Log http traffic in ADF devServer?

It is 1.9. In my post it shows how I am configuring webpack dev server. But I shortened some of it for the post.

devServer: proxy."/ecm"

is actually

devServer: {

  proxy: {

    "/ecm": {

      ...

    }

    ...

  }

  ...

}

dvuika
Alfresco Employee

Re: Log http traffic in ADF devServer?

You should get a working example if you generate a new 2.0.0 app with latest yeoman generator. You can also generate to a separate folder and compare the configurations.

eugenio_romano
Alfresco Employee

Re: Log http traffic in ADF devServer?

queshaw
Member II

Re: Log http traffic in ADF devServer?

This a reply to Denys also. Yes,ADF CORS solving strategies is one of the articles I based the configuration on.

The yeoman generator does create a working example for me. I was also looking into the demo-shell in alfresco-ng2-components and before posting this question it was the demo shell I was having trouble with.

In the yeoman generated app, changing the log level in proxy.conf.json to debug was enough for me to figure out my immediate problem.

I would like to know how to log network traffic of the  proxy with the angular-cli based app, but I am going to continue with the yeoman generator.

dvuika
Alfresco Employee

Re: Log http traffic in ADF devServer?

You can also check the "serve" command docs from the Angular CLI: serve · angular/angular-cli Wiki · GitHub You most probably need the "verbose mode". You can modify the "package.json" script (the "start" one) with extra switches. Hope that helps.