diff --git a/voicevox_engine/app/middlewares.py b/voicevox_engine/app/middlewares.py index 3c44a2125..14fd9e1f2 100644 --- a/voicevox_engine/app/middlewares.py +++ b/voicevox_engine/app/middlewares.py @@ -28,7 +28,9 @@ async def global_execution_handler(request: Request, exc: Exception) -> Response app.add_middleware(ServerErrorMiddleware, handler=global_execution_handler) # CORS用のヘッダを生成するミドルウェア - localhost_regex = "^https?://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?$" + localhost_regex = ( + r"^[a-zA-Z+\-\.]+://(([^/]+\.)localhost|127\.0\.0\.1|\[::1\])(:[0-9]+)?$" + ) compiled_localhost_regex = re.compile(localhost_regex) allowed_origins = ["*"] if cors_policy_mode == "localapps":