|
| 1 | +--- |
| 2 | +title: Accessing the configuration |
| 3 | +--- |
| 4 | + |
| 5 | +Whenever you start a Wasp app, you are starting two processes. |
| 6 | + - **The client process** - A React app that implements your app's frontend. |
| 7 | + |
| 8 | + During development, this is a dev server with hot reloading. In production, |
| 9 | + it's a simple process that serves pre-built static files with environment variables |
| 10 | + embedded during the build (details depend on [how you deploy |
| 11 | + it](/docs/advanced/deployment/overview)). |
| 12 | + |
| 13 | + - **The server process** - An Express server that implements your app's backend. |
| 14 | + |
| 15 | + During development, this is an Express server controlled by a |
| 16 | + [`nodemon`](https://www.npmjs.com/package/nodemon) process that takes care of |
| 17 | + hot reloading and restarts. In production, it's a regular Express server run |
| 18 | + using Node. |
| 19 | + |
| 20 | +Check [the introduction](/docs) for a more in-depth explanation of Wasp's runtime architecture. |
| 21 | + |
| 22 | +You can configure both processes through environment variables. See [the |
| 23 | +deployment instructions](/docs/advanced/deployment/manually#environment-variables) for a full list |
| 24 | +of supported variables. |
| 25 | + |
| 26 | +Wasp gives you runtime access to the processes' configurations through **configuration objects**. |
| 27 | + |
| 28 | +## Server configuration object |
| 29 | + |
| 30 | +The server configuration object contains these fields: |
| 31 | + |
| 32 | +- `frontendUrl: String` - Set it with env var `WASP_WEB_CLIENT_URL`. |
| 33 | + |
| 34 | + The URL of your client (the app's frontend).<br/> |
| 35 | + Wasp automatically sets it during development when you run `wasp start`.<br/> |
| 36 | + In production, you should set it to your client's URL as the server sees it |
| 37 | + (i.e., with the DNS and proxies considered). |
| 38 | + |
| 39 | +You can access it like this: |
| 40 | +```js |
| 41 | +import { config } from 'wasp/server' |
| 42 | + |
| 43 | +console.log(config.frontendUrl) |
| 44 | +``` |
| 45 | + |
| 46 | +## Client configuration object |
| 47 | +The client configuration object contains these fields: |
| 48 | +- `apiUrl: String` - Set it with env var `REACT_APP_API_URL` |
| 49 | + |
| 50 | + The URL of your server (the app's backend).<br/> |
| 51 | + Wasp automatically sets it during development when you run `wasp start`.<br/> |
| 52 | + In production, it should contain the value of your server's URL as the user's browser |
| 53 | + sees it (i.e., with the DNS and proxies considered). |
| 54 | + |
| 55 | +You can access it like this: |
| 56 | +```js |
| 57 | +import { config } from 'wasp/client' |
| 58 | + |
| 59 | +console.log(config.apiUrl) |
| 60 | +``` |
0 commit comments