404 when installing my first cloud addon

Dritan Xhabija May 17, 2018

Hello,

I have followed instructions for creating my own Addon via  node.js https://bitbucket.org/atlassian/atlassian-connect-express?_ga=2.196421675.604162594.1526506219-323932314.1487801975

 

I am running my node.js server on AWS and I have it configured with SSL (took a few days of configuration).

 

After overcoming SSL errors when trying to add a new add-on, I am now faced with this 404 error:

The add-on host returned HTTP response code 404 when we tried to contact it during installation. Please try again later or contact the add-on vendor.

 

How can I obtain better logs than Audit Logs? I'd like to find the root cause. I'm running on a free development instance to get the plugin/add-on working.

 

I have configured config.json and atlassian-connect.json to have the correct URL.

I keep seeing this "/installed" URL needs to have a route, so I added [app.get('/installed')] and [app.post('/installed')] inside routes/index.js

 

Nothing seems to be working. Does anyone have any ideas?

 

Thank you in advance,

Dritan

5 answers

1 vote
Jeremy Wells July 23, 2020

This issue is a little silly; it's caused by the baseUrl in `atlassian-connect.json` being incorrect.

The baaseUrl in `atlassian-connect.json` is static, but when you run `npm start` ngrok assigns a new dynamic url that doesn't match what is in the `atlassian-connect.json`.

Unless you dynamically get the ngrok url when the app is running and overwrite it in `atlassian-connect.json` at runtime, this will never work properly.

Here's a simple workaround...

- run `ngrok http 3000` in terminal (adjust port accordingly if you're not using 3000)
- copy the `https://{ngrok_address}` value from ngrok output in terminal (leave ngrok running)
- past the ngrok url into the `atlassian-connect.json` as baseUrl
- open a new terminal
- run `npm start`


1 vote
Dritan Xhabija May 21, 2018

Hi Peter,

Prior to posting here I already did the simple tutorial with ngrok from local machine which generates an HTTPS link for installing to cloud JIRA. But that tutorial was not very useful with static html data that doesn't make use of the very same framework you're advertising for add-ons.

 

None of the links you provided actually explain happening under the hood with atlassian-connect so I can debug the step causing the 404.

Those tutorials/guides could be more useful if they were more technically descriptive. For instance:

- first it takes the localBaseUrl from config.json and propagates it everywhere including atlassian-connect.json

- second, atlassian-connect checks that the routes defined in the json have valid folder paths

- third ... 

 

As you can see, I've already gone through the effort to go beyond local machine relying on 3rd party ngrok, I have set up a public secure server from which this add-on will live. I just need to get through the preliminaries and finally utilize your APIs to create my 'functional requirement' add-on.

 

How can I get more detailed logs as to what is causing the 404? Was this "add-on" component not designed for developers in mind - who are technical - who need verbose logs instead of "something went wrong"? 

 

I'd love to get technical support with this issue.

 

Thank you,

Dritan

Guilherme Schumacher September 20, 2018

Dritan, did you get any response on this issue or have you found any solution? I'm stuck exactly in this situation. My atlassian-connect.json is invisible to the browser and to JIRA (returns 404).

Like Syed Farhan likes this
Michiel Oliemans September 23, 2018

Had exactly the same problem just now. On a hunch I decided to have the homepage return an empty HTML as well. Hadn't defined anything for that one, so it was returning a 404 before. After adding an empty HTML page it continues to the next step. Rather important piece of information...

Like Guilherme Schumacher likes this
Dan Williams October 14, 2018

I too was having this issue.  My solution was to remove the 

addon.authenticate(),

 section of the code.  I'm not sure why the authenticate wasn't working since I had generated an API token etc... but I'll look into that at a later time.  

Like Guilherme Schumacher likes this
Syed Farhan January 13, 2020

Having the same issue. The plugin was working fairly before but now its 404. 

Like # people like this
0 votes
MikePineda February 20, 2020

My plugin was working before but now I have the same problem. 

My solution was:

  • Remove the addon.authenticate() from the routes.
  • Add the following route handler:
    app.post('//installed', function (req, res) {
         res.send(200);
    };
0 votes
Syed Farhan January 23, 2020
app.get("/atlassian-connect.json", (req, res, next) => { const isHttps = req.secure || req.header("x-forwarded-proto") === "https";
return res.status(200).json({ apiMigrations: { gdpr: true }, name: "Headlines for Jira", description: "This plugin shows the recent updated tickets and branches of all projects a user is working on", key: "headlines-jira", baseUrl: `${isHttps ? "https" : "http"}://${req.get("host")}`, lifecycle: { installed: "/jira/events/install", uninstalled: "/jira/events/uninstall", enabled: "/jira/events/enabled", disabled: "/jira/events/disabled" }, vendor: { name: "Productbox", url: "https://www.productbox.dev" }, authentication: { type: "jwt" }, scopes: ["READ", "ACT_AS_USER"], apiVersion: 1, modules: { generalPages: [ { key: "headlines", location: "system.top.navigation.bar", name: { value: "Headlines" }, url: "/headlines", conditions: [ { condition: "user_is_logged_in" } ] } ] } }); });

Thats what I did and it worked 

0 votes
Peter Van de Voorde
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 18, 2018

Hi @Dritan Xhabija,

Do you know which url you are calling that gives you a 404?

I would take a look at the Jira Cloud getting started guide: https://developer.atlassian.com/cloud/jira/platform/getting-started/

Or the Confluence Cloud getting started guide: https://developer.atlassian.com/cloud/confluence/getting-started/

Both of those have extra information on how Atlassian Connect Express works.

I would also recommend that you build it on your local machine first and use ngrok to make it available on the internet. That will exclude all AWS related problems.

I also want to invite you into our Developer Community: https://community.developer.atlassian.com. It's a separate community for people who are building apps on top of our products.

Cheers,

Peter

Suggest an answer

Log in or Sign up to answer