Get plugin configuration
(request: Request, token: str = Depends(verify_admin_token))
| 2282 | |
| 2283 | @router.get("/api/plugin/config") |
| 2284 | async def get_plugin_config(request: Request, token: str = Depends(verify_admin_token)): |
| 2285 | """Get plugin configuration""" |
| 2286 | plugin_config = await db.get_plugin_config() |
| 2287 | |
| 2288 | # Get the actual domain and port from the request |
| 2289 | # This allows the connection URL to reflect the user's actual access path |
| 2290 | host_header = request.headers.get("host", "") |
| 2291 | |
| 2292 | # Generate connection URL based on actual request |
| 2293 | if host_header: |
| 2294 | # Use the actual domain/IP and port from the request |
| 2295 | connection_url = f"http://{host_header}/api/plugin/update-token" |
| 2296 | else: |
| 2297 | # Fallback to config-based URL |
| 2298 | from ..core.config import config |
| 2299 | server_host = config.server_host |
| 2300 | server_port = config.server_port |
| 2301 | |
| 2302 | if server_host == "0.0.0.0": |
| 2303 | connection_url = f"http://127.0.0.1:{server_port}/api/plugin/update-token" |
| 2304 | else: |
| 2305 | connection_url = f"http://{server_host}:{server_port}/api/plugin/update-token" |
| 2306 | |
| 2307 | return { |
| 2308 | "success": True, |
| 2309 | "config": { |
| 2310 | "connection_token": plugin_config.connection_token, |
| 2311 | "connection_url": connection_url, |
| 2312 | "auto_enable_on_update": plugin_config.auto_enable_on_update |
| 2313 | } |
| 2314 | } |
| 2315 | |
| 2316 | |
| 2317 | @router.post("/api/plugin/config") |
nothing calls this directly
no test coverage detected