mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
fix: use relative URLs in web mode to leverage Vite proxy
In web mode, the API client was hardcoding localhost:3008, which bypassed the Vite proxy and caused CORS errors. Now it uses relative URLs (just /api) in web mode, allowing the proxy to handle routing and making requests appear same-origin. - Web mode: Use relative URLs for proxy routing (no CORS issues) - Electron mode: Continue using hardcoded localhost:3008 This allows the Vite proxy configuration to actually work in web mode. Fixes: Persistent CORS errors in web mode development Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,12 @@ const getServerUrl = (): string => {
|
|||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
const envUrl = import.meta.env.VITE_SERVER_URL;
|
const envUrl = import.meta.env.VITE_SERVER_URL;
|
||||||
if (envUrl) return envUrl;
|
if (envUrl) return envUrl;
|
||||||
|
|
||||||
|
// In web mode (not Electron), use relative URL to leverage Vite proxy
|
||||||
|
// This avoids CORS issues since requests appear same-origin
|
||||||
|
if (!window.electron) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Use VITE_HOSTNAME if set, otherwise default to localhost
|
// Use VITE_HOSTNAME if set, otherwise default to localhost
|
||||||
const hostname = import.meta.env.VITE_HOSTNAME || 'localhost';
|
const hostname = import.meta.env.VITE_HOSTNAME || 'localhost';
|
||||||
|
|||||||
Reference in New Issue
Block a user