spa-to-http icon indicating copy to clipboard operation
spa-to-http copied to clipboard

Support for a base url option

Open bmarsaud opened this issue 3 months ago • 0 comments

Hi! Thanks for your work on this image.

I'm publishing an SPA on a subpath, let's say on https://example.com/app/. I want to serve :

  • My index.html on /app
  • My static assets on /app/assets/xxxx
  • Redirect my SPA routes (/app/route1 for instance) to the index.html

For now, my static assets are not served properly because it will search for /app/assets/xxxx files ont the fs instead of /assets/xxxx. A base url option, would allow to match the incoming URL with the file path.

A workaround is to copy the static assets to the "base url path" in the image fs while keeping the index.html on root :

FROM devforth/spa-to-http:latest AS runner
ARG BASE_URL="app"
RUN mkdir -p ${BASE_URL}
COPY --from=build /usr/src/app/dist ${BASE_URL}
RUN mv ${BASE_URL}/index.html index.html

But I think a runtime option would make it cleaner. It's the same issue as https://github.com/devforth/spa-to-http/issues/11 that was closed

Would like to submit a PR but i don't know GO tbh!

bmarsaud avatar Oct 08 '25 07:10 bmarsaud