I wanted to use Forge remote to have my forge app connect to a Netflify function but I can’t seem to get it to work.
I tried to folllow the documentation and my manifest looks like the folllowing
modules:
jira:issuePanel:
- key: user-by-reference-group
title: User reference by group
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
resource: trigger-resources
resolver:
endpoint: create-user-api-endpoint
function:
- key: trigger-function
handler: index.run
endpoint:
- key: create-user-api-endpoint
remote: create-user-api-func
resources:
- key: trigger-resources
path: static/dist
tunnel:
port: 3000
permissions:
content:
styles:
- unsafe-inline
scopes: []
remotes:
- key: create-user-api-func
baseUrl: https://user-group-reference.netlify.app
app:
id: ari:cloud:ecosystem::app/597aae01-e322-4c97-a926-f18cd7124f3a
somewhere in my code I am trying to invoke the remote like the following
const handleClick = async () => {
try {
const response = await invokeRemote({
method: "GET",
path: "/api/forge",
});
setData(JSON.stringify(response));
} catch (error: any) {
setData(error);
}
};
But nothing is happening.
I also tried to install the demo application that mentioned in the documentation and it doesn’t work either.
Am I doing something wrong or Forge remote features doesn’t work at all?
Hello @YvesIvadHABIMANA,
I am also using Forge Remote and it works fine without any problems.
Your manifest file looks correct to me. Are you sure that the latest version of your code is deployed and running? Can you place some console.log
lines to see what is happening?
const handleClick = async () => {
try {
console.log("Sending request...");
const response = await invokeRemote({
method: "GET",
path: "/api/forge",
});
console.log("Result:", response);
setData(JSON.stringify(response));
} catch (error: any) {
console.log("Error:", error);
setData(error);
}
};
1 Like
Hello @Berkayztrk I have tried to log, but since my code is running from a Custom UI environment using React. I was not able to see the logs.
I tried to display the response in the UI by rendering the stringfied state using JSON.stringify(data)
but I always get an empty object as output
You should be able to see the logs in your browser’s dev tools console. I also use Custom UI & React and can see the log outputs in the browser console.
I am only able to see logs when I don’t use anything from @forge/bridge
when I do I get the following error
I inspected using graphql dev tools and I get the following error
{
"data": {
"invokeExtension": {
"success": false,
"response": null,
"contextToken": null,
"errors": [
{
"message": "Invalid response from remote",
"extensions": {
"errorType": "INVALID_REMOTE_INVOCATION_ERROR",
"statusCode": 400,
"__typename": "GenericMutationErrorExtension"
},
"__typename": "MutationError"
}
],
"__typename": "InvokeExtensionResponse"
}
},
"extensions": {
"gateway": {
"request_id": "174e9474718242a7aebe1d09ac013589",
"crossRegion": false,
"edgeCrossRegion": false
}
}
}
It looks like your backend endpoint returns an invalid response. What is the format of the response expected to be returned from the Netlify url?
It can return anything. I am currently just returning a json object
I managed to get it to work. I needed to also register the path I was trying to get.
here is the changes I made in the manifest file
- key: create-user-api-endpoint
remote: create-user-api-func
route:
path: /.netlify/functions/forge
auth:
appUserToken:
enabled: true
appSystemToken:
enabled: true
1 Like