Help finding my PEBKAC with Forge Tunnel

TL;DR Forge Tunnel never works for me with Custom UI. In fact, I can reproduce this 100% of the time with an out of the box app made by Forge Create. Outlining what I do below so people can help me figure out what I am doing wrong.

Create the app:

(base) boris@Boriss-MBP abrega % forge create
Creating an app in your current directory:

    /Users/boris/repo/abrega

Press Ctrl+C to cancel.

Name your app. The app name can include dashes, spaces, and underscores.

? Enter a name for your app: broken-custom-uitunnel-demo

Start with a template. Each template contains the required files to be a valid app.

? Select a category: Custom UI
? Select a product: Confluence
? Select a template: confluence-macro

 ✔ Creating app...

ℹ Downloading template
ℹ Registering app
ℹ Creating environments
ℹ Installing dependencies

✔ Created broken-custom-uitunnel-demo

Your app is ready to work on, deploy, and install. We created 3 environments you can deploy to: production, staging, development.

Change to directory broken-custom-uitunnel-demo to see your app files.
(base) boris@Boriss-MBP abrega % cd broken-custom-uitunnel-demo 
(base) boris@Boriss-MBP broken-custom-uitunnel-demo % 

Add the tunnel and port per https://developer.atlassian.com/platform/forge/tunneling/#connecting-the-tunnel-to-your-own-dev-server so the manifest looks like this:

modules:
  macro:
    - key: broken-custom-uitunnel-demo-hello-world
      resource: main
      resolver:
        function: resolver
      title: broken-custom-uitunnel-demo
      description: Inserts Hello world!
  function:
    - key: resolver
      handler: index.handler
resources:
  - key: main
    path: static/hello-world/build
    tunnel:
      port: 3000
app:
  id: ari:cloud:ecosystem::app/2a88daff-91c3-4ec7-aceb-ac1c7250c04d
cd static/helo-world
npm i
npm run build
npm run start

in a new tab:

forge deploy
forge install

Go to confluence and add the macro to the page.
Inspect the element, and see that the macro is being loaded from CDN:

src="https://5cecd9b9-b383-4579-8a56-a6178d990925.cdn.prod.atlassian-dev.net/2a88daff-91c3-4ec7-aceb-ac1c7250c04d/677639ba-2b20-4d66-8896-21a9c773a57a/5598003d-f5b2-4d85-ab1d-ead515130757/main/_hostname_abrega-dev.atlassian.net/"

Start your tunnel:
forge tunnel --ngrok-config ~/.ngrok2/ngrok.yml

Reload the page. No forge function is run in the tunnel.
Inspect the page, and it’s still pulling from CDN.

Hello Boris,

What output is visible from your forge tunnel (...) command? Your minimal test-case is working on my env as expected:

stefan@lucyfer:~/temp/broken-custom-uitunnel-demo$ forge tunnel --ngrok-config ~/.ngrok2/ngrok.yml
Tunnel redirects requests you make to your local machine. This occurs for any Atlassian site where your app is installed in the specific development environment. You will not see requests from other users.
Press Ctrl+C to cancel.

Checking Docker image... 100%   
Your Docker image is up to date.

=== Running forge lint...
No issues found.

=== Bundling code...
✔ Functions bundled.

=== Snapshotting functions...
No log output.


Listening for requests...

Received proxy request. Serving file index.html for resource main from specified address http://localhost:3000

Error: Failed to connect to localhost:3000. Check that your service is running.

^ Failure to connect is expected: I didn’t bother to run up npm run start assuming it is irrelevant to your case.

One thing that comes to my mind: with which user are you logged into your Confluence instance? Are you sure it is the same Atlassian user as the one reported by forge whoami command? Maybe this is the difference preventing tunnel use?

2 Likes

There is nothing at https://developer.atlassian.com/platform/forge/tunneling/ which documents any such requirement as far as I can tell.

I use forge signed into the “shared” account so I can deploy to prod.

Tunnel requests to backend functions (in Securely) work fine with this config btw. The issue is only with Custom UI.

1 Like

I think @stefan-ok might be onto something. I, as well, believe that Custom UI only tunnels the connections for the same user that is logged in.

1 Like

Confirmed that having the forge login user different from the user logged into Atlassian web interface was the issue. Doesn’t seem to be documented anywhere.

@danielwinterw I believe we discussed this at Atlas Camp. Not sure if this is a bug or a feature (should this be the case for backend functions as well?) or a doc miss or something, but would be nice to get this handled.

1 Like