REST Proxy module

Developer productivity Unbundled: Framework Version 2.0.0 Magnolia 6.3 compatible

Issues

Git

Git

The REST Proxy module is used to proxy REST calls to another API via Magnolia. It ensures API connection details like API keys or other security information are hidden from the browser. Since it ensures sensitive information is obfuscated, it secures API calls from a frontend. You can use the REST Proxy module to build connections to customer data platforms, leverage the power of Large Language Models (LLMs), and much more.

This module is at the INCUBATOR level.

Installing with Maven

Maven is the easiest way to install the module. Add the following to your bundle:

<dependency>
  <groupId>info.magnolia.restproxy</groupId>
  <artifactId>magnolia-rest-proxy</artifactId>
  <version>2.0.0</version>
</dependency>

Configuration

The configuration consists of two parts. A REST endpoint that is exposed by Magnolia and a REST client that requests to the endpoint are proxied to.

REST endpoint

<light-module-name>/restEndpoints/<restEndpointName>.yaml
class: info.magnolia.restproxy.service.ConfiguredRestProxyEndpointDefinition
restClientName: <REST_CLIENT_NAME> (1)
restCallName: <REST_CLIENT_METHOD_NAME> (2)
excludedHeaders: (3)
  <HEADER_NAME_1>: <HEADER_VALUE_1>
  <HEADER_NAME_2>: <HEADER_VALUE_2>
1 Replace with the actual REST client name.
2 Method name such as GET, PUT, POST.
3 The definition of excluded headers such as transfer-encoding: 'Transfer-Encoding'

REST client

Below is an example for the REST client.

  • The method configured in the client can use get or post but the endpoint exposed by Magnolia must be called via post.

  • The endpoint can only proxy requests to one method. To expose multiple methods from the same API, configure multiple endpoints.

See the The endpointPath property to see how how endpoints configured in the same light module directory are exposed under a common path segment.

<light-module-name>/restClients/<restClientName>.yaml
baseUrl: <URL to the existing service> (1)
securitySchemes:
  b1:
    $type: basic
    username: <username for the existing service>
    password: <password for the existing service>
restCalls:
  <REST_CLIENT_METHOD_NAME>: (2)
    method: get
    path: /<path of the method>/${idProperty}
    securityScheme: b1
1 Be sure to add your value to baseUrl.
2 Be sure to add your method here.

Example call from Frontend

await fetch('/.rest/<REST_CLIENT_NAME>', { (1)
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: `{"idProperty":"${idProperty}"}`
});
1 Be sure to put your own REST_CLIENT_NAME.

Changelog

Version Notes

2.0.0

6.3 compatibility release.

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the REST Proxy module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules