Use Fiddler as middle man of Atlassian Connect Express App and disable cache

  • fennng 

Atlassian provides a nodejs based framework to aid atlassian connect app development. This framework is based on nodejs + espressjs + handlebars. It will also use ngrok to expose local port to internet. For more information, please refer to following link.

bitbucket.org/atlassian/atlassian-connect-express/src/master/

The javascript files in the routes folder (index.js etc) are executed by the nodejs engine from server side. For any changes in these files, you have to run npm start again to take effect. (nodemon can be helpful).

The javascript in public folder is on the other hand executed by the client (browsers), any changes made in these files should not require restarting the dev server. But because the browser caches the javascript files, you still need to restart the dev server using npm start.

I will show you a way to use fiddler to disable cache. Also fiddler will be act as man in the middle so that you can view and modify request/response.

Before you start, you should have a working atlassian connect plugin code.

1. First, we need to config fiddler as a reserve proxy. Press ALT+Q in fidder, and enter !listen 3001. This will ask fiddler to listen to port 3001. Make sure 3001 is not used by other program.

2. Press Ctrl + R to open fiddler config files. Navigate to OnBeforeRequest method and add following code in the end of this method. Once fiddler receive a request from ngrok, it will forward it to port 3000.


if (IsMatch(oSession.host, "ngrok.io")){				
  oSession.host = "localhost:3000";
  return;
}

3. Now go to Fiddler ‘s Rules -> Performance and tick “Disable caching”.

4. Now Leave fiddler open, open \node_modules\atlassian-connect-express\lib\internal\registration\register-jira-conf.js with any text editor, change addon.config.port() to addon.config.port()+1. This make ngrok to map 80 port to 3001 (the default port is 3000).


5. Now the config is done. Use npm start to run the project. You should see the traffic from Atlassian could goes into fiddler and is redirected to port 3000.

Notes (not important):

When “Disable caching” is turned on in Fiddler, fiddler will remove the cache header from HTTP request. You can find the following code in fiddler script.

if (m_DisableCaching)
              {
                oSession.oRequest.headers.Remove("If-None-Match");
                oSession.oRequest.headers.Remove("If-Modified-Since");
                oSession.oRequest["Pragma"] = "no-cache";
              }

发表评论

您的电子邮箱地址不会被公开。