Class SpaIndexTransformer

java.lang.Object
org.operaton.bpm.spring.boot.starter.webapp.neo.SpaIndexTransformer
All Implemented Interfaces:
org.springframework.web.servlet.resource.ResourceTransformer

public class SpaIndexTransformer extends Object implements org.springframework.web.servlet.resource.ResourceTransformer
Rewrites the <base href> of the SPA shell to the application root, so the bundle can be served from a sub-path.

Nothing in the bundle can know its own prefix at build time: it is the sum of the servlet context path (known per request) and operaton.bpm.webapp.neo.application-path. The one place a browser reads a prefix from is <base href>, so the server states it here and everything the SPA emits — assets, locales, routes — hangs off it.

Only index.html is transformed; every other resource passes through untouched.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
    protected static final Pattern
    The <base href="..."> the frontend build emits (see index.html).
    protected static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpaIndexTransformer(String applicationPath)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    appRoot(jakarta.servlet.http.HttpServletRequest request)
    The application root as the browser must see it: context path + application path, with a trailing slash so relative URLs resolve inside the app rather than beside it.
    org.springframework.core.io.Resource
    transform(jakarta.servlet.http.HttpServletRequest request, org.springframework.core.io.Resource resource, org.springframework.web.servlet.resource.ResourceTransformerChain transformerChain)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INDEX_HTML

      protected static final String INDEX_HTML
      See Also:
    • BASE_TAG

      protected static final Pattern BASE_TAG
      The <base href="..."> the frontend build emits (see index.html).
    • applicationPath

      protected final String applicationPath
  • Constructor Details

    • SpaIndexTransformer

      public SpaIndexTransformer(String applicationPath)
  • Method Details

    • transform

      public org.springframework.core.io.Resource transform(jakarta.servlet.http.HttpServletRequest request, org.springframework.core.io.Resource resource, org.springframework.web.servlet.resource.ResourceTransformerChain transformerChain) throws IOException
      Specified by:
      transform in interface org.springframework.web.servlet.resource.ResourceTransformer
      Throws:
      IOException
    • appRoot

      protected String appRoot(jakarta.servlet.http.HttpServletRequest request)
      The application root as the browser must see it: context path + application path, with a trailing slash so relative URLs resolve inside the app rather than beside it.