Following the example app, I am trying to set up Forge Remote with a hosted server. However, before any request hits the server, I am getting this error:
Error: Remote could not verify the Forge Invocation Token
I combed through the stack trace and it seems it fails in the getCallBridge
function of @forge/bridge but I can’t figure out why.
Here is the code:
import React, {useEffect, useState} from 'react';
import ForgeReconciler, { Inline } from '@forge/react';
import { invokeRemote } from '@forge/bridge';
const App = () => {
const [data, setData] = useState<any>(null);
useEffect(() => {
invokeRemote({
method: 'POST',
path: '/test'
}).then(res => {
console.log("RESPONSE")
setData(res);
})
}, []);
if (data) {
const res = data.body;
return (
<>
<Inline> Remote results:</Inline>
<Inline> {res.test ? 'Test success!' : 'Test fail :('}</Inline>
</>
);
}
return (
<Inline>Performing Remote Invocation...</Inline>
)
};
ForgeReconciler.render(
<App />
);
Bump - still having this issue.
Hi @MattGudenas,
You normally run into this error when your remote server returns a 401 from the invocation request. Can you please check the behaviour of your remote server and make sure that you are validating remote requests correctly, here is a link to the documentation
1 Like
@BoZhang the code does not hit the remote server at all.
I should clarify that I have checked the network tab and there is no request being sent from the Bitbucket app. There is nothing returning 401 either. So there is something wrong with the setup on the UI side.
Oh that’s interesting, can you have a look at the logs under the developer console (instructions)?
In terms of why you aren’t seeing any relevant in the network tab of your browser tools, when you call invokeRemote()
, it will actually make a call to Forge, where we perform several pre-invocation checks and hydrate the requests with OAuth tokens (if you have configured for these to be sent) , Forge will then send the request to your remote server.
@BoZhang After a lot of debugging, I finally managed to figure out what was happening. So this not seeing anything on the network tab was indeed a red herring. I was not seeing anything on the backend side either because the config on manifest.yml was not propagating the port correctly. Even though I had
tunnel:
port: 3000
I actually had to add the port to the url and only then did it work. This may be a peculiarity of the remote server as well.
1 Like
Sorry please what URL did you add the port to? and what port are we talking about here, the port where your backend is running or the forge ui?
Because I can’t seem to fix mine
@VictorAmadi I was running my remote server on gitpod and the port of that server had to be added to the URL of the remote server in order for it to work. Something like https://3000-remote-server-url.gitpod.cloud/
Hope that makes sense.
oh okay… well I have my remote backend hosted and now I’m using ngrok
more importantly, the headers that are supposed to be part of the request are not even coming through to my backend