Commit a72eb3e2 authored by Arunoda Susiripala's avatar Arunoda Susiripala

Support production deployments to ZEIT now via path alias.

parent 7540bc52
...@@ -42,3 +42,30 @@ These rules are based on ZEIT now [path alias](https://zeit.co/docs/features/pat ...@@ -42,3 +42,30 @@ These rules are based on ZEIT now [path alias](https://zeit.co/docs/features/pat
* All pages should be unique across zones. A page with the same name should not exist in multiple zones. Otherwise, there'll be unexpected behaviour in client side navigation. * All pages should be unique across zones. A page with the same name should not exist in multiple zones. Otherwise, there'll be unexpected behaviour in client side navigation.
* According to the above example, a page named `blog` should not be exist in the `home` zone. * According to the above example, a page named `blog` should not be exist in the `home` zone.
## Production Deployment
Here's how are going to deploy this application into production.
* Open the `now.json` file in both `blog` and `home` directories and change the aliases as you wish.
* Then update `rules-prod.json` accordingly.
* Now deploy both apps:
~~~sh
cd home
now && now alias
cd ../blog
now && now alias
cd ..
~~~
* Finally, set the path alias rules with
~~~sh
now alias with-zones.now.sh -r rules-prod.json
~~~
> You can use a domain name of your choice in the above command instead of `with-zones.now.sh`.
That's it.
Now you can access the final app via: <https://with-zones.now.sh>
const { NOW_URL } = process.env
const { alias } = require('./now.json')
module.exports = { module.exports = {
assetPrefix: 'http://localhost:5000' assetPrefix: NOW_URL ? `https://${alias}` : 'http://localhost:5000'
} }
{
"alias": "with-zones-blog.now.sh"
}
{
"name": "with-zones-blog",
"version": "1.0.0",
"scripts": {
"build": "next build",
"start": "next start -p 4000"
},
"dependencies": {
"next": "zones",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"license": "ISC"
}
const { NOW_URL } = process.env
const { alias } = require('./now.json')
module.exports = { module.exports = {
assetPrefix: 'http://localhost:4000' assetPrefix: NOW_URL ? `https://${alias}` : 'http://localhost:4000'
} }
{
"alias": "with-zones-home.now.sh"
}
{
"name": "with-zones-home",
"version": "1.0.0",
"scripts": {
"build": "next build",
"start": "next start -p 4000"
},
"dependencies": {
"next": "zones",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"license": "ISC"
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"blog": "next blog -p 5000", "blog": "next blog -p 5000",
"blog-build": "next build blog", "blog-build": "next build blog",
"blog-start": "next start blog -p 5000", "blog-start": "next start blog -p 5000",
"proxy": "micro-proxy -r rules.json" "proxy": "micro-proxy -r rules-dev.json"
}, },
"dependencies": { "dependencies": {
"micro-proxy": "^1.0.0", "micro-proxy": "^1.0.0",
......
{
"rules": [
{"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "https://with-zones-blog.now.sh"},
{"pathname": "/**", "dest": "https://with-zones-home.now.sh"}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment