The Action Proxy allows you to call other APIs without needing to add the Terrakube frontend to the CORS settings, which is particularly useful if you don't have access to configure CORS. Additionally, it can be used to inject Workspace variables and Global variables into your requests.
The proxy supports POST, GET, PUT, and DELETE methods. You can access it using the axiosInstance
variable, which contains an Axios object.
To invoke the proxy, use the following URL format: ${context.apiUrl}/proxy/v1
When calling the Action Proxy, use the following required parameters:
targetUrl: Contains the URL that you want to invoke.
proxyHeaders: Contains the headers that you want to send to the target URL.
workspaceId: The workspace ID that will be used for some validations from the proxy side
If you need to access sensitive keys or passwords from your API call, you can inject variables using the template notation ${{var.variable_name}}
, where variable_name
represents a Workspace variable or a Global variable.
If you have a Global variable and a Workspace variable with the same name, the Workspace variable value will take priority.
Example Usage
In this example:
${{var.OPENAI_API_KEY}}
is a placeholder for a sensitive key that will be injected by the proxy.
proxyBody
contains the data to be sent in the request body.
proxyHeaders
contains the headers to be sent to the target URL.
targetUrl
specifies the API endpoint to be invoked.
workspaceId
is used for validations on the proxy side.
By using the Action Proxy, you can easily interact with external APIs while using Terrakube's capabilities to manage and inject necessary variables securely.