title: How do I get Kongs X-Forwarded-Prefix Header into Spring Boot Application and its HATEOAS links?
body: <p>i'm having a Spring Boot application that is accessed through Kong API Gateway. Because of this, the self links provided by Spring are wrong.</p>
  
  <p>The URL to access my application via Kong is the following:
      <a href="https://api.anything.de/myapplication/test/countries/" rel="nofollow noreferrer">https://api.anything.de/myapplication/test/countries/</a></p>
  
  <p>But the self links look like that:
      <a href="https://api.anything.de/countries/5a4cf88a45a64a97a7cdb38c" rel="nofollow noreferrer">https://api.anything.de/countries/5a4cf88a45a64a97a7cdb38c</a></p>
  
  <p>So as you can see, the prefix "/myapplication/test" is missing in the self links.</p>
  
  <p>Thats why i tried to add X-Forwarded-Prefix in the config of Kong.</p>
  
  <p>This is my entry in the config.yml of Kong:</p>
  
  <pre><code>  - name: MyApplicationTest
      plugins:
        - name: request-transformer
          attributes:
            enabled: true
            config:
              add:
                headers:
                  - 'X-Forwarded-Prefix:/myapplication/test'
      attributes:
        uris:
          - /myapplication/test
        strip_uri: true
        preserve_host: false
        upstream_url: 'http://&lt;IP&gt;/my-application-test'
  </code></pre>
  
  <p>In the application.yml of my application I have this:</p>
  
  <pre><code>server:
      port: 8080
      compression:
          enabled: true
          mime-types: application/json
      use-forward-headers: true
  </code></pre>
  
  <p>My class Application.java looks like that:</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
      @Bean
      FilterRegistrationBean forwardedHeaderFilter() {
          FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
          filterRegistrationBean.setFilter(new ForwardedHeaderFilter());
          filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
          return filterRegistrationBean;
      }
  }
  </code></pre>
  
  <p>Because I wanted to know if my applictaion receives the Header from Kong I have a end point to see the headers. But there is no X-Forwarded-Prefix header.</p>
  
  <p>Does anybody know what I'm missing or have an idea how to fix this?</p>
  
  <p>Thank you!</p>