How to modify API URL?

Issue

  • If we are removing the /o/ from URLs, they are not recognised anymore.

Environment

  • Liferay DXP 7.1+

Resolution

  • You can create a hostname e.g. api.something.com and have Apache (or Nginx) do the proxy pass to Liferay with /o.
     
    Below is a sample configuration could be implemented e.g. on localhost
     
    httpd.conf extract:
     
    <VirtualHost *:80>
    ServerName api.localhost

    ProxyTimeout 300
    ProxyRequests on
    ProxyPreserveHost On

    <Location />
    ProxyPass http://localhost:8080/o/
    ProxyPassReverse http://localhost:8080/o/
    </Location>

    </VirtualHost>
     
    With this setting API can be accessed as the following URL:
     
    http://api.localhost/headless-delivery/v1.0/sites/20121/content-elements
     
    Instead of http://localhost:8080/o/headless-delivery/v1.0/sites/20121/content-elements

 

Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0