Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): error early on incompatible config (apiHost and apiUrl) (#…
…9808) I was working on Redwood's server config with @Josh-Walker-GM. One of the more unfortunate footguns is when you're serving the web side alone while the api side is somewhere else, on a completely different host. If you don't pass `apiHost`, and `apiUrl` isn't fully qualified, what happens is that the web side requests itself, resulting in network responses like this: <img width="1532" alt="image" src="https://github.com/redwoodjs/redwood/assets/32992335/21c6f3ec-5614-4336-9967-1ab4c25ea7db"> An easy fix that would go a long way is just erroring out if we detect the config is incompatible and not starting the server at all: ``` # In redwood.toml, apiUrl is `/.redwood/functions`, a relative URL, and apiHost isn't passed the at the CLI: % yarn rw serve web Error: If you don't provide apiHost, apiUrl needs to be a fully-qualified URL. But apiUrl is /.redwood/functions. ``` We used a specific exit code because `yarn rw serve web` is a bin that's calling a bin `yarn rw-server-web`. We plan to fix that by deduping code across packages, so this specific exit code is just a stopgap till we get that work done. The reason we're doing this fix first is that again, it's easy and would solve a big problem. We referenced this doc on exit code conventions which stated that 64-113 was up for grabs: https://tldp.org/LDP/abs/html/exitcodes.html.
- Loading branch information