-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated example * Added single now.json * Added Multi Zones docs * Fix titles * Added back the deploy button
- Loading branch information
Luis Alvarez D
authored
Mar 26, 2020
1 parent
4801dcd
commit a391d32
Showing
12 changed files
with
81 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Multi Zones | ||
|
||
<details> | ||
<summary><b>Examples</b></summary> | ||
<ul> | ||
<li><a href="/examples/with-zones">With Zones</a></li> | ||
</ul> | ||
</details> | ||
|
||
A zone is a single deployment of a Next.js app. You can have multiple zones and merge them as a single app. | ||
|
||
For example, let's say you have the following apps: | ||
|
||
- An app for serving `/blog/**` | ||
- Another app for serving all other pages | ||
|
||
With multi zones support, you can merge both these apps into a single one allowing your customers to browse it using a single URL, but you can develop and deploy both apps independently. | ||
|
||
## How to define a zone | ||
|
||
There are no special zones related APIs. You only need to do following: | ||
|
||
- Make sure to keep only the pages you need in your app, meaning that an app can't have pages from another app, if app `A` has `/blog` then app `B` shouldn't have it too. | ||
- Make sure to add an [assetPrefix](/docs/api-reference/next.config.js/cdn-support-with-asset-prefix.md) to avoid conflicts with static files. | ||
|
||
## How to merge zones | ||
|
||
You can merge zones using any HTTP proxy. | ||
|
||
For [ZEIT Now](https://zeit.co/now), you can use a single `now.json` to deploy both apps. It allows you to easily define routing routes for multiple apps like below: | ||
|
||
```json | ||
{ | ||
"version": 2, | ||
"builds": [ | ||
{ "src": "blog/package.json", "use": "@now/next" }, | ||
{ "src": "home/package.json", "use": "@now/next" } | ||
], | ||
"routes": [ | ||
{ "src": "/blog/_next(.*)", "dest": "blog/_next$1" }, | ||
{ "src": "/blog(.*)", "dest": "blog/blog$1" }, | ||
{ "src": "(.*)", "dest": "home$1" } | ||
] | ||
} | ||
``` | ||
|
||
You can also configure a proxy server to route using a set of routes like the ones above, e.g deploy the blog app to `https://blog.example.com` and the home app to `https://home.example.com` and then add a proxy server for both apps in `https://example.com`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": 2, | ||
"build": { | ||
"env": { | ||
"BUILDING_FOR_NOW": "true" | ||
} | ||
}, | ||
"builds": [ | ||
{ "src": "blog/package.json", "use": "@now/next" }, | ||
{ "src": "home/package.json", "use": "@now/next" } | ||
], | ||
"routes": [ | ||
{ "src": "/blog/_next(.*)", "dest": "blog/_next$1" }, | ||
{ "src": "/blog(.*)", "dest": "blog/blog$1" }, | ||
{ "src": "(.*)", "dest": "home$1" } | ||
] | ||
} |