You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: {{cookiecutter.project_slug}}/README.md
+49-36Lines changed: 49 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,43 +215,27 @@ If you are using **Docker Toolbox** in Windows or macOS instead of **Docker for
215
215
216
216
The address of your Docker Toolbox virtual machine would probably be `192.168.99.100` (that is the default).
217
217
218
-
As this is a common case, the domain `local.dockertoolbox.tiangolo.com` points to that (private) IP, just to help with development. That way, you can start the stack in Docker Toolbox, and use that domain for development. You will be able to open that URL in Chrome and it will communicate with your local Docker Toolbox directly as if it was a cloud server, including CORS (Cross Origin Resource Sharing).
218
+
As this is a common case, the domain `local.dockertoolbox.tiangolo.com` points to that (private) IP, just to help with development (actually `dockertoolbox.tiangolo.com` and all its subdomains point to that IP). That way, you can start the stack in Docker Toolbox, and use that domain for development. You will be able to open that URL in Chrome and it will communicate with your local Docker Toolbox directly as if it was a cloud server, including CORS (Cross Origin Resource Sharing).
219
219
220
-
To use it, you need to tell your backend that it is running on that domain, you will have to edit a couple files.
220
+
If you used the default CORS enabled domains while generating the project, `local.dockertoolbox.tiangolo.com` was configured to be allowed. If you didn't, you will need to add it to the list in the variable `BACKEND_CORS_ORIGINS` in the `.env` file.
221
221
222
-
* Open the file located at `./.env`. It would have 2 lines like:
222
+
To configure it in your stack, follow the section **Change the development "domain"** below, using the domain `local.dockertoolbox.tiangolo.com`.
223
223
224
-
```
225
-
DOMAIN=localhost
226
-
# DOMAIN=local.dockertoolbox.tiangolo.com
227
-
```
228
-
229
-
* Switch the comment, change the section to:
224
+
After performing those steps you should be able to open: http://local.dockertoolbox.tiangolo.com and it will be server by your stack in your Docker Toolbox virtual machine.
230
225
231
-
```
232
-
# DOMAIN=localhost
233
-
DOMAIN=local.dockertoolbox.tiangolo.com
234
-
```
235
-
236
-
That variable will be used by the `docker-compose.dev.env.yml` file. That's one of the Docker Compose files used by default. It will set the environment variable `SERVER_NAME` to that host. Without that change, you would receive 404 HTTP errors and "Cross Origin Resource Sharing" (CORS) errors.
226
+
Check all the corresponding available URLs in the section at the end.
237
227
238
-
* Now open the file located at `./frontend/.env`. It would have a line like:
228
+
### Develpment in `localhost` with a custom domain
You might want to use something different than `localhost` as the domain. For example, if you are having problems with cookies that need a subdomain, and Chrome is not allowing you to use `localhost`.
244
231
245
-
* Change that line to:
232
+
In that case, you have two options: you could use the instructions to modify your system `hosts` file with the instructions below in **Development with a custom IP** or you can just use `localhost.tiangolo.com`, it is set up to point to `localhost` (to the IP `127.0.0.1`) and all its subdomains too. And as it is an actual domain, the browsers will store the cookies you set during development, etc.
If you used the default CORS enabled domains while generating the project, `localhost.tiangolo.com` was configured to be allowed. If you didn't, you will need to add it to the list in the variable `BACKEND_CORS_ORIGINS` in the `.env` file.
251
235
252
-
That variable will make your frontend communicate with that domain when interacting with the API, when the other variable `VUE_APP_ENV` is set to `development`.
236
+
To configure it in your stack, follow the section **Change the development "domain"** below, using the domain `localhost.tiangolo.com`.
253
237
254
-
Now you can open: http://local.dockertoolbox.tiangolo.com and it will be server by your Docker Toolbox.
238
+
After performing those steps you should be able to open: http://localhost.tiangolo.com and it will be server by your stack in `localhost`.
255
239
256
240
Check all the corresponding available URLs in the section at the end.
257
241
@@ -261,6 +245,8 @@ If you are running Docker in an IP address different than `127.0.0.1` (`localhos
261
245
262
246
In that case, you will need to use a fake local domain (`dev.{{cookiecutter.domain_main}}`) and make your computer think that the domain is is served by the custom IP (e.g. `192.168.99.150`).
263
247
248
+
If you used the default CORS enabled domains, `dev.{{cookiecutter.domain_main}}` was configured to be allowed. If you want a custom one, you need to add it to the list in the variable `BACKEND_CORS_ORIGINS` in the `.env` file.
249
+
264
250
* Open your `hosts` file with administrative privileges using a text editor:
265
251
***Note for Windows**: If you are in Windows, open the main Windows menu, search for "notepad", right click on it, and select the option "open as Administrator" or similar. Then click the "File" menu, "Open file", go to the directory `c:\Windows\System32\Drivers\etc\`, select the option to show "All files" instead of only "Text (.txt) files", and open the `hosts` file.
266
252
***Note for Mac and Linux**: Your `hosts` file is probably located at `/etc/hosts`, you can edit it in a terminal running `sudo nano /etc/hosts`.
@@ -278,39 +264,51 @@ The new line might look like:
278
264
279
265
...that will make your computer think that the fake local domain is served by that custom IP, and when you open that URL in your browser, it will talk directly to your locally running server when it is asked to go to `dev.{{cookiecutter.domain_main}}` and think that it is a remote server while it is actually running in your computer.
280
266
281
-
Now you need to make sure the stack uses that domain.
267
+
To configure it in your stack, follow the section **Change the development "domain"** below, using the domain `dev.{{cookiecutter.domain_main}}`.
268
+
269
+
After performing those steps you should be able to open: http://dev.{{cookiecutter.domain_main}} and it will be server by your stack in `localhost`.
270
+
271
+
### Change the development "domain"
272
+
273
+
If you need to use your local stack with a different domain than `localhost`, you need to make sure the domain you use points to the IP where your stack is set up. See the different ways to achieve that in the sections above (i.e. using Docker Toolbox with `local.dockertoolbox.tiangolo.com`, using `localhost.tiangolo.com` or using `dev.{{cookiecutter.domain_main}}`).
274
+
275
+
To simplify your Docker Compose setup, for example, so that the API explorer, Swagger UI, knows where is your API, you should let it know you are using that domain for development. You will need to edit 1 line in 2 files.
282
276
283
277
* Open the file located at `./.env`. It would have a line like:
284
278
285
279
```
286
280
DOMAIN=localhost
287
281
```
288
282
289
-
* Change that line to:
283
+
* Change it to the domain you are going to use, e.g.:
290
284
291
285
```
292
-
DOMAIN=dev.{{cookiecutter.domain_main}}
286
+
DOMAIN=localhost.tiangolo.com
293
287
```
294
288
295
-
That variable will be used by the `docker-compose.dev.env.yml`file. That's one of the Docker Compose files used by default. It will set the environment variable `SERVER_NAME`to that host. Without that change, you would receive 404 HTTP errors and "Cross Origin Resource Sharing" (CORS) errors.
289
+
That variable will be used by some of the local development `docker-compose.dev.*.yml` files, for example, to tell Swagger UI to use that domain for the API.
296
290
297
291
* Now open the file located at `./frontend/.env`. It would have a line like:
298
292
299
293
```
300
294
VUE_APP_DOMAIN_DEV=localhost
301
295
```
302
296
303
-
* Change that line to:
297
+
* Change that line to the domain you are going to use, e.g.:
That variable will make your frontend communicate with that domain when interacting with the API, when the other variable `VUE_APP_ENV` is set to `development`.
303
+
That variable will make your frontend communicate with that domain when interacting with your backend API, when the other variable `VUE_APP_ENV` is set to `development`.
310
304
311
-
Now you can open: http://dev.{{cookiecutter.domain_main}} and it will be server by your Docker Toolbox.
305
+
After changing the two lines, you can re-start your stack with:
312
306
313
-
Check all the corresponding available URLs in the section at the end.
307
+
```bash
308
+
docker-compose up -d
309
+
```
310
+
311
+
and check all the corresponding available URLs in the section at the end.
0 commit comments