prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Unable to access data in Feast UI when deployed to remote instance
  ## Expected Behavior 
  Should be able to view registry data when launching UI with `feast ui` on remote instances (like EC2).
  
  ## Current Behavior
  I’ve tried setting the host to `0.0.0.0`  and the static assets get loaded and can accessed via the public IP. But the requests to the registry (`http://0.0.0.0:8888/registry`) fails, so no data shows up.
  
  I've also tried setting the host to the private IP, but the request to `/registry` times out.
  
  ## Steps to reproduce
  Run `feast ui --host <instance private ip>` in EC2 instance.
  
  ### Specifications
  
  - Version:`0.21.2`
  - Platform: EC2
  - Subsystem:
  
  ## Possible Solution
  Potential CORS issue that needs to be fixed?
  Unable to access data in Feast UI when deployed to remote instance
  ## Expected Behavior 
  Should be able to view registry data when launching UI with `feast ui` on remote instances (like EC2).
  
  ## Current Behavior
  I’ve tried setting the host to `0.0.0.0`  and the static assets get loaded and can accessed via the public IP. But the requests to the registry (`http://0.0.0.0:8888/registry`) fails, so no data shows up.
  
  I've also tried setting the host to the private IP, but the request to `/registry` times out.
  
  ## Steps to reproduce
  Run `feast ui --host <instance private ip>` in EC2 instance.
  
  ### Specifications
  
  - Version:`0.21.2`
  - Platform: EC2
  - Subsystem:
  
  ## Possible Solution
  Potential CORS issue that needs to be fixed?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sdk/python/feast/ui_server.py`
  Content:
  ```
  1 import json
  2 import threading
  3 from typing import Callable, Optional
  4 
  5 import pkg_resources
  6 import uvicorn
  7 from fastapi import FastAPI, Response
  8 from fastapi.middleware.cors import CORSMiddleware
  9 from fastapi.staticfiles import StaticFiles
  10 
  11 import feast
  12 
  13 
  14 def get_app(
  15     store: "feast.FeatureStore",
  16     get_registry_dump: Callable,
  17     project_id: str,
  18     registry_ttl_secs: int,
  19     host: str,
  20     port: int,
  21 ):
  22     app = FastAPI()
  23 
  24     app.add_middleware(
  25         CORSMiddleware,
  26         allow_origins=["*"],
  27         allow_credentials=True,
  28         allow_methods=["*"],
  29         allow_headers=["*"],
  30     )
  31 
  32     # Asynchronously refresh registry, notifying shutdown and canceling the active timer if the app is shutting down
  33     registry_json = ""
  34     shutting_down = False
  35     active_timer: Optional[threading.Timer] = None
  36 
  37     def async_refresh():
  38         store.refresh_registry()
  39         nonlocal registry_json
  40         registry_json = get_registry_dump(store.config, store.repo_path)
  41         if shutting_down:
  42             return
  43         nonlocal active_timer
  44         active_timer = threading.Timer(registry_ttl_secs, async_refresh)
  45         active_timer.start()
  46 
  47     @app.on_event("shutdown")
  48     def shutdown_event():
  49         nonlocal shutting_down
  50         shutting_down = True
  51         if active_timer:
  52             active_timer.cancel()
  53 
  54     async_refresh()
  55 
  56     ui_dir = pkg_resources.resource_filename(__name__, "ui/build/")
  57     # Initialize with the projects-list.json file
  58     with open(ui_dir + "projects-list.json", mode="w") as f:
  59         projects_dict = {
  60             "projects": [
  61                 {
  62                     "name": "Project",
  63                     "description": "Test project",
  64                     "id": project_id,
  65                     "registryPath": f"http://{host}:{port}/registry",
  66                 }
  67             ]
  68         }
  69         f.write(json.dumps(projects_dict))
  70 
  71     @app.get("/registry")
  72     def read_registry():
  73         return json.loads(registry_json)
  74 
  75     # For all other paths (such as paths that would otherwise be handled by react router), pass to React
  76     @app.api_route("/p/{path_name:path}", methods=["GET"])
  77     def catch_all():
  78         filename = ui_dir + "index.html"
  79 
  80         with open(filename) as f:
  81             content = f.read()
  82 
  83         return Response(content, media_type="text/html")
  84 
  85     app.mount(
  86         "/", StaticFiles(directory=ui_dir, html=True), name="site",
  87     )
  88 
  89     return app
  90 
  91 
  92 def start_server(
  93     store: "feast.FeatureStore",
  94     host: str,
  95     port: int,
  96     get_registry_dump: Callable,
  97     project_id: str,
  98     registry_ttl_sec: int,
  99 ):
  100     app = get_app(store, get_registry_dump, project_id, registry_ttl_sec, host, port)
  101     uvicorn.run(app, host=host, port=port)
  102
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sdk/python/feast/ui_server.py b/sdk/python/feast/ui_server.py
  --- a/sdk/python/feast/ui_server.py
  +++ b/sdk/python/feast/ui_server.py
  @@ -62,7 +62,7 @@
                       "name": "Project",
                       "description": "Test project",
                       "id": project_id,
  -                    "registryPath": f"http://{host}:{port}/registry",
  +                    "registryPath": "/registry",
                   }
               ]
           }
  
verification_info: {"golden_diff": "diff --git a/sdk/python/feast/ui_server.py b/sdk/python/feast/ui_server.py\n--- a/sdk/python/feast/ui_server.py\n+++ b/sdk/python/feast/ui_server.py\n@@ -62,7 +62,7 @@\n                     \"name\": \"Project\",\n                     \"description\": \"Test project\",\n                     \"id\": project_id,\n-                    \"registryPath\": f\"http://{host}:{port}/registry\",\n+                    \"registryPath\": \"/registry\",\n                 }\n             ]\n         }\n", "issue": "Unable to access data in Feast UI when deployed to remote instance\n## Expected Behavior \r\nShould be able to view registry data when launching UI with `feast ui` on remote instances (like EC2).\r\n\r\n## Current Behavior\r\nI\u2019ve tried setting the host to `0.0.0.0`  and the static assets get loaded and can accessed via the public IP. But the requests to the registry (`http://0.0.0.0:8888/registry`) fails, so no data shows up.\r\n\r\nI've also tried setting the host to the private IP, but the request to `/registry` times out.\r\n\r\n## Steps to reproduce\r\nRun `feast ui --host <instance private ip>` in EC2 instance.\r\n\r\n### Specifications\r\n\r\n- Version:`0.21.2`\r\n- Platform: EC2\r\n- Subsystem:\r\n\r\n## Possible Solution\r\nPotential CORS issue that needs to be fixed?\nUnable to access data in Feast UI when deployed to remote instance\n## Expected Behavior \r\nShould be able to view registry data when launching UI with `feast ui` on remote instances (like EC2).\r\n\r\n## Current Behavior\r\nI\u2019ve tried setting the host to `0.0.0.0`  and the static assets get loaded and can accessed via the public IP. But the requests to the registry (`http://0.0.0.0:8888/registry`) fails, so no data shows up.\r\n\r\nI've also tried setting the host to the private IP, but the request to `/registry` times out.\r\n\r\n## Steps to reproduce\r\nRun `feast ui --host <instance private ip>` in EC2 instance.\r\n\r\n### Specifications\r\n\r\n- Version:`0.21.2`\r\n- Platform: EC2\r\n- Subsystem:\r\n\r\n## Possible Solution\r\nPotential CORS issue that needs to be fixed?\n", "before_files": [{"content": "import json\nimport threading\nfrom typing import Callable, Optional\n\nimport pkg_resources\nimport uvicorn\nfrom fastapi import FastAPI, Response\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.staticfiles import StaticFiles\n\nimport feast\n\n\ndef get_app(\n    store: \"feast.FeatureStore\",\n    get_registry_dump: Callable,\n    project_id: str,\n    registry_ttl_secs: int,\n    host: str,\n    port: int,\n):\n    app = FastAPI()\n\n    app.add_middleware(\n        CORSMiddleware,\n        allow_origins=[\"*\"],\n        allow_credentials=True,\n        allow_methods=[\"*\"],\n        allow_headers=[\"*\"],\n    )\n\n    # Asynchronously refresh registry, notifying shutdown and canceling the active timer if the app is shutting down\n    registry_json = \"\"\n    shutting_down = False\n    active_timer: Optional[threading.Timer] = None\n\n    def async_refresh():\n        store.refresh_registry()\n        nonlocal registry_json\n        registry_json = get_registry_dump(store.config, store.repo_path)\n        if shutting_down:\n            return\n        nonlocal active_timer\n        active_timer = threading.Timer(registry_ttl_secs, async_refresh)\n        active_timer.start()\n\n    @app.on_event(\"shutdown\")\n    def shutdown_event():\n        nonlocal shutting_down\n        shutting_down = True\n        if active_timer:\n            active_timer.cancel()\n\n    async_refresh()\n\n    ui_dir = pkg_resources.resource_filename(__name__, \"ui/build/\")\n    # Initialize with the projects-list.json file\n    with open(ui_dir + \"projects-list.json\", mode=\"w\") as f:\n        projects_dict = {\n            \"projects\": [\n                {\n                    \"name\": \"Project\",\n                    \"description\": \"Test project\",\n                    \"id\": project_id,\n                    \"registryPath\": f\"http://{host}:{port}/registry\",\n                }\n            ]\n        }\n        f.write(json.dumps(projects_dict))\n\n    @app.get(\"/registry\")\n    def read_registry():\n        return json.loads(registry_json)\n\n    # For all other paths (such as paths that would otherwise be handled by react router), pass to React\n    @app.api_route(\"/p/{path_name:path}\", methods=[\"GET\"])\n    def catch_all():\n        filename = ui_dir + \"index.html\"\n\n        with open(filename) as f:\n            content = f.read()\n\n        return Response(content, media_type=\"text/html\")\n\n    app.mount(\n        \"/\", StaticFiles(directory=ui_dir, html=True), name=\"site\",\n    )\n\n    return app\n\n\ndef start_server(\n    store: \"feast.FeatureStore\",\n    host: str,\n    port: int,\n    get_registry_dump: Callable,\n    project_id: str,\n    registry_ttl_sec: int,\n):\n    app = get_app(store, get_registry_dump, project_id, registry_ttl_sec, host, port)\n    uvicorn.run(app, host=host, port=port)\n", "path": "sdk/python/feast/ui_server.py"}], "after_files": [{"content": "import json\nimport threading\nfrom typing import Callable, Optional\n\nimport pkg_resources\nimport uvicorn\nfrom fastapi import FastAPI, Response\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom fastapi.staticfiles import StaticFiles\n\nimport feast\n\n\ndef get_app(\n    store: \"feast.FeatureStore\",\n    get_registry_dump: Callable,\n    project_id: str,\n    registry_ttl_secs: int,\n    host: str,\n    port: int,\n):\n    app = FastAPI()\n\n    app.add_middleware(\n        CORSMiddleware,\n        allow_origins=[\"*\"],\n        allow_credentials=True,\n        allow_methods=[\"*\"],\n        allow_headers=[\"*\"],\n    )\n\n    # Asynchronously refresh registry, notifying shutdown and canceling the active timer if the app is shutting down\n    registry_json = \"\"\n    shutting_down = False\n    active_timer: Optional[threading.Timer] = None\n\n    def async_refresh():\n        store.refresh_registry()\n        nonlocal registry_json\n        registry_json = get_registry_dump(store.config, store.repo_path)\n        if shutting_down:\n            return\n        nonlocal active_timer\n        active_timer = threading.Timer(registry_ttl_secs, async_refresh)\n        active_timer.start()\n\n    @app.on_event(\"shutdown\")\n    def shutdown_event():\n        nonlocal shutting_down\n        shutting_down = True\n        if active_timer:\n            active_timer.cancel()\n\n    async_refresh()\n\n    ui_dir = pkg_resources.resource_filename(__name__, \"ui/build/\")\n    # Initialize with the projects-list.json file\n    with open(ui_dir + \"projects-list.json\", mode=\"w\") as f:\n        projects_dict = {\n            \"projects\": [\n                {\n                    \"name\": \"Project\",\n                    \"description\": \"Test project\",\n                    \"id\": project_id,\n                    \"registryPath\": \"/registry\",\n                }\n            ]\n        }\n        f.write(json.dumps(projects_dict))\n\n    @app.get(\"/registry\")\n    def read_registry():\n        return json.loads(registry_json)\n\n    # For all other paths (such as paths that would otherwise be handled by react router), pass to React\n    @app.api_route(\"/p/{path_name:path}\", methods=[\"GET\"])\n    def catch_all():\n        filename = ui_dir + \"index.html\"\n\n        with open(filename) as f:\n            content = f.read()\n\n        return Response(content, media_type=\"text/html\")\n\n    app.mount(\n        \"/\", StaticFiles(directory=ui_dir, html=True), name=\"site\",\n    )\n\n    return app\n\n\ndef start_server(\n    store: \"feast.FeatureStore\",\n    host: str,\n    port: int,\n    get_registry_dump: Callable,\n    project_id: str,\n    registry_ttl_sec: int,\n):\n    app = get_app(store, get_registry_dump, project_id, registry_ttl_sec, host, port)\n    uvicorn.run(app, host=host, port=port)\n", "path": "sdk/python/feast/ui_server.py"}]}