mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(amp): add /threads.rss root-level route for AMP CLI
AMP CLI requests /threads.rss at the root level, but the AMP module only registered routes under /api/*. This caused a 404 error during AMP CLI startup. Add the missing root-level route with the same security middleware (noCORS, optional localhost restriction) as other management routes.
This commit is contained in:
@@ -111,6 +111,14 @@ func (m *AmpModule) registerManagementRoutes(engine *gin.Engine, baseHandler *ha
|
|||||||
ampAPI.Any("/otel", proxyHandler)
|
ampAPI.Any("/otel", proxyHandler)
|
||||||
ampAPI.Any("/otel/*path", proxyHandler)
|
ampAPI.Any("/otel/*path", proxyHandler)
|
||||||
|
|
||||||
|
// Root-level routes that AMP CLI expects without /api prefix
|
||||||
|
// These need the same security middleware as the /api/* routes
|
||||||
|
rootMiddleware := []gin.HandlerFunc{noCORSMiddleware()}
|
||||||
|
if restrictToLocalhost {
|
||||||
|
rootMiddleware = append(rootMiddleware, localhostOnlyMiddleware())
|
||||||
|
}
|
||||||
|
engine.GET("/threads.rss", append(rootMiddleware, proxyHandler)...)
|
||||||
|
|
||||||
// Google v1beta1 passthrough with OAuth fallback
|
// Google v1beta1 passthrough with OAuth fallback
|
||||||
// AMP CLI uses non-standard paths like /publishers/google/models/...
|
// AMP CLI uses non-standard paths like /publishers/google/models/...
|
||||||
// We bridge these to our standard Gemini handler to enable local OAuth.
|
// We bridge these to our standard Gemini handler to enable local OAuth.
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ func TestRegisterManagementRoutes(t *testing.T) {
|
|||||||
{"/api/meta", http.MethodGet},
|
{"/api/meta", http.MethodGet},
|
||||||
{"/api/telemetry", http.MethodGet},
|
{"/api/telemetry", http.MethodGet},
|
||||||
{"/api/threads", http.MethodGet},
|
{"/api/threads", http.MethodGet},
|
||||||
|
{"/threads.rss", http.MethodGet}, // Root-level route (no /api prefix)
|
||||||
{"/api/otel", http.MethodGet},
|
{"/api/otel", http.MethodGet},
|
||||||
// Google v1beta1 bridge should still proxy non-model requests (GET) and allow POST
|
// Google v1beta1 bridge should still proxy non-model requests (GET) and allow POST
|
||||||
{"/api/provider/google/v1beta1/models", http.MethodGet},
|
{"/api/provider/google/v1beta1/models", http.MethodGet},
|
||||||
|
|||||||
Reference in New Issue
Block a user