bentosmau commited on
Commit ·
8d24498
1
Parent(s): 0fb39a4
Update application to correctly use public domain for connections
Browse filesUpdate Vite proxy configuration to forward necessary headers and modify app.py to dynamically set the root_path using the REPLIT_DEV_DOMAIN environment variable, ensuring correct public URL construction for Gradio.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e3ff2484-bbd8-4aba-bea0-1940769b874a
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ebea0a47-6931-4712-9f39-0e5c99a1fd37
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1739408b-93a5-479b-a658-30f2493b0467/e3ff2484-bbd8-4aba-bea0-1940769b874a/ytKS716
Replit-Helium-Checkpoint-Created: true
- artifacts/neo1-chat/vite.config.ts +9 -0
- chat-app/app.py +3 -1
artifacts/neo1-chat/vite.config.ts
CHANGED
|
@@ -72,6 +72,15 @@ export default defineConfig({
|
|
| 72 |
changeOrigin: true,
|
| 73 |
rewrite: (path) => path.replace(/^\/__neo1/, ""),
|
| 74 |
ws: true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
},
|
| 76 |
},
|
| 77 |
},
|
|
|
|
| 72 |
changeOrigin: true,
|
| 73 |
rewrite: (path) => path.replace(/^\/__neo1/, ""),
|
| 74 |
ws: true,
|
| 75 |
+
configure: (proxy) => {
|
| 76 |
+
proxy.on("proxyReq", (proxyReq, req) => {
|
| 77 |
+
const host = (req.headers["x-forwarded-host"] as string) || req.headers.host || "";
|
| 78 |
+
if (host) {
|
| 79 |
+
proxyReq.setHeader("X-Forwarded-Host", host);
|
| 80 |
+
proxyReq.setHeader("X-Forwarded-Proto", "https");
|
| 81 |
+
}
|
| 82 |
+
});
|
| 83 |
+
},
|
| 84 |
},
|
| 85 |
},
|
| 86 |
},
|
chat-app/app.py
CHANGED
|
@@ -202,10 +202,12 @@ with gr.Blocks(title="mdfjbots-neo-1") as demo:
|
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
port = int(os.environ.get("PORT", 5000))
|
|
|
|
|
|
|
| 205 |
demo.launch(
|
| 206 |
server_name="0.0.0.0",
|
| 207 |
server_port=port,
|
| 208 |
share=False,
|
| 209 |
theme=gr.themes.Soft(primary_hue="blue"),
|
| 210 |
-
root_path=
|
| 211 |
)
|
|
|
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
port = int(os.environ.get("PORT", 5000))
|
| 205 |
+
dev_domain = os.environ.get("REPLIT_DEV_DOMAIN", "")
|
| 206 |
+
root_path = f"https://{dev_domain}/__neo1" if dev_domain else "/__neo1"
|
| 207 |
demo.launch(
|
| 208 |
server_name="0.0.0.0",
|
| 209 |
server_port=port,
|
| 210 |
share=False,
|
| 211 |
theme=gr.themes.Soft(primary_hue="blue"),
|
| 212 |
+
root_path=root_path,
|
| 213 |
)
|