package com.cameleer.server.app.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * SPA catch-all: forwards non-API, non-static requests to {@code index.html}
 * so that React Router can handle client-side routing.
 * <p>
 * Only active when the UI is embedded (i.e., {@code static/index.html} exists
 * in the classpath). When running standalone via Nginx, this is not needed.
 */
@Controller
public class SpaForwardController {

    @GetMapping(value = {
            "/login",
            "/executions",
            "/executions/**",
            "/oidc/callback",
            "/admin/**"
    })
    public String forward() {
        return "forward:/index.html";
    }
}
