diff --git a/frontend/Caddyfile b/frontend/Caddyfile deleted file mode 100644 index 7e9e9dfb66..0000000000 --- a/frontend/Caddyfile +++ /dev/null @@ -1,12 +0,0 @@ -:80 { - bind {$ADDRESS} - reverse_proxy /api/* http://localhost:8000 - reverse_proxy /* http://localhost:3000 - reverse_proxy /ws/* http://localhost:3001 -} - -:443 { - bind {$ADDRESS} - reverse_proxy /api/* http://localhost:8000 - reverse_proxy /ws/* http://localhost:3001 -} diff --git a/frontend/CaddyfileDev b/frontend/CaddyfileDev deleted file mode 100644 index 1ae524c0a5..0000000000 --- a/frontend/CaddyfileDev +++ /dev/null @@ -1,12 +0,0 @@ -{ - auto_https off -} - -:8080 { - bind {$ADDRESS} - reverse_proxy /api/* http://localhost:8000 - reverse_proxy /* http://localhost:3000 - reverse_proxy /ws/* http://lsp:3001 { - lb_policy header "Authorization" - } -} diff --git a/frontend/CaddyfileLsp b/frontend/CaddyfileLsp deleted file mode 100644 index eb86cda7e2..0000000000 --- a/frontend/CaddyfileLsp +++ /dev/null @@ -1,14 +0,0 @@ -http://localhost { - bind {$ADDRESS} - reverse_proxy /api/* https://app.windmill.dev { - header_up Host {http.reverse_proxy.upstream.hostport} - } - reverse_proxy /* http://localhost:3000 -} - - -https://localhost { - bind {$ADDRESS} - reverse_proxy /ws/* http://localhost:3001 -} - diff --git a/frontend/CaddyfileRemote b/frontend/CaddyfileRemote deleted file mode 100644 index fceb5be316..0000000000 --- a/frontend/CaddyfileRemote +++ /dev/null @@ -1,17 +0,0 @@ -http://localhost { - bind {$ADDRESS} - reverse_proxy /api/* https://app.windmill.dev { - header_up Host {http.reverse_proxy.upstream.hostport} - header_down Set-Cookie windmill.dev localhost - } - reverse_proxy /* http://localhost:3000 -} - - -https://localhost { - bind {$ADDRESS} - reverse_proxy /ws/* https://app.windmill.dev { - header_up Host {http.reverse_proxy.upstream.hostport} - } -} - diff --git a/frontend/README_DEV.md b/frontend/README_DEV.md index 9d0c978f85..19b0d79683 100644 --- a/frontend/README_DEV.md +++ b/frontend/README_DEV.md @@ -1,25 +1,41 @@ # Developing -## Starting The Development Server +- install the dependencies with `npm install` (or `pnpm install` or `yarn`) +- generate the windmill client: -Once you've created a project and installed dependencies with `npm install` (or -`pnpm install` or `yarn`), start a development server: +```bash +npm run generate-backend-client +## on mac use +npm run generate-backend-client-mac +``` + +Once the dependencies are installed, just start the dev server: ```bash npm run dev ``` -To have the whole stack backing your dev environment, 3 solutions: +The default proxy is setup to use the remote backend: . + +You can configure another proxy to use like so: + +```bash +REMOTE=http://localhost:8000 REMOTE_LSP=http://localhost:3000 npm run dev +``` + +## Use a Local backend ### 1. Backend is run by docker -In the root folder: - ```bash docker build . -t windmill docker compose up db windmill_server windmill_worker ``` +```bash +REMOTE=http://localhost REMOTE_LSP=http://localhost npm run dev +``` + ### 2. Backend is run by cargo **Prerequisites** @@ -40,10 +56,7 @@ docker compose up db windmill_server windmill_worker - To test that you have Rust and Cargo installed run `cargo --version` -- In your terminal, go to the backend directory and run `cargo build` -- Run `cargo run` - -**Known issue on M1 Mac while running `cargo build`** +**Known issue on M1 Mac while running `cargorun`** - You may encounter `linking with cc failed` build time error. - To solve this run: @@ -52,38 +65,6 @@ docker compose up db windmill_server windmill_worker source ~/.zshrc ``` -**Do a Frontend Build** - -In order to run the backend, you need to have a frontend build inside `frontend/build/`. - -Otherwise, `cargo run` will break. - -So, in the frontend folder, run: - -```bash -# !!! on OSX, you are not allowed to use the system SED, but you need to use GNU SED. -# !!! thus, in `frontend/package.json`, replace all `sed` occurences with `gsed`. - -# prerequisite for build -npm run generate-backend-client -## on mac use -npm run generate-backend-client-mac - -npm run build -# now, you'll have a `frontend/build` folder. -``` - -**Known issue while running `npm run build`** - -- You may encounter `FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory` error. -- To solve this run: - -```bash -export NODE_OPTIONS=--max_old_space_size=8096 -``` - -- run `npm run build` again - In the root folder: ```bash @@ -96,38 +77,16 @@ In the backend folder: DATABASE_URL=postgres://postgres:changeme@127.0.0.1:5433/windmill?sslmode=disable cargo run ``` -You can now access [http://127.0.0.1:8000](http://127.0.0.1:8000). - -### In both cases - In the frontend folder: ```bash -sudo caddy run --config ./Caddyfile +REMOTE=http://localhost:8000 REMOTE_LSP=http://localhost:3000 npm run dev ``` -(sudo is required to bind port 80 and 443) - -and then go to - -### 3. Backend is run by remote! - -```bash -sudo caddy run --config ./CaddyfileRemote -``` - -and then go to - ## Building ```bash -npm run build -``` - -## Generating the backend client automatically - -```bash -npm run generate-backend-client +NODE_OPTIONS=--max_old_space_size=8096 npm run build ``` ## Formatting diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 74edcdaf5c..f3f8d2f3cd 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -9,7 +9,20 @@ const version = JSON.parse(json) /** @type {import('vite').UserConfig} */ const config = { server: { - port: 3000 + port: 3000, + proxy: { + '^/api/.*': { + target: process.env.REMOTE ?? 'https://app.windmill.dev/', + changeOrigin: true, + cookieDomainRewrite: 'localhost' + }, + // Proxying websockets or socket.io: ws://localhost:5173/socket.io -> ws://localhost:5174/socket.io + '^/ws/.*': { + target: process.env.REMOTE_LSP ?? 'https://app.windmill.dev', + changeOrigin: true, + ws: true + } + } }, preview: { port: 3000