spring-projects / spring-projects/spring-boot

Support client side routing out of the box

Open
#27,554 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

There's no obvious out of the box way to configure Spring Boot for client side routing with single page applications.
Most solutions found online rely on separation of paths such that you can easily tell frontend paths from API but this is not always possible. Also even that requires writing some extra code for what is nowadays an extremely common case and looks like everybody is reinventing this wheel poorly.

Most other web servers can be easily configured to serve index when static file can't be found.

Please add single property that enables such behavior, e.g. spring.resources.redirect-if-missing=/ that should forward to / in case requested resource was not found in spring.resources.static-locations.

Alternatively suggest how to implement it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Spring Boot's handling of requested resources configured through spring.resources.static-locations, and compare the requested behavior with the proposed spring.resources.redirect-if-missing property. Define how an unfound resource should fall back to / without interfering with API paths, then verify that the single-page application entry point is served as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.