Deployment guides - Zeit Now

Last year we learned that stale-while-revalidate is the best cache technique for this type of architecture. At that moment, only KeyCDN and StackPath supported it.

We got in contact with Now because it didn’t work with their CDN. It looks like they have finally fixed it:

They call it “Serverless Pre-Rendering” but I think we should stick to the real name, stale-while-revalidate.

Anyway, I think that our first deployment guide could be Now because it’s serverless, it’s cheap and it’s easy to set up. For what I see, their CDN works now on external domains as well.

2 Likes

EDIT: New instructions

We have created a Now Builder and now it’s much simpler to use:

{
  "alias": "www.your-site.com", // CHANGE THIS!
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@frontity/now"
    }
  ]
}

More information in the official guide:

https://docs.frontity.org/installation-and-deploy/deploy-on-now


EDIT: Old instructions (use the new!)

These are the instructions to deploy in Zeit Now:

  1. Install the now package in your project:
npm install --save-dev now
  1. Add this now.json file:
{
  "version": 2,
  "alias": ["www.your-site.com"], // CHANGE THIS!
  "builds": [
    {
      "src": "build/static/*",
      "use": "@now/static"
    },
    {
      "src": "favicon.ico",
      "use": "@now/static"
    },
    {
      "src": "build/server.js",
      "use": "@now/node"
    }
  ],
  "routes": [
    {
      "src": "/static/(.*)",
      "headers": {
        "cache-control": "max-age=31536000,s-maxage=31536000,immutable"
      },
      "dest": "/build/static/$1"
    },
    { "src": "/favicon.ico", "dest": "/favicon.ico" },
    {
      "src": "/(.*)",
      "headers": { "cache-control": "s-maxage=1,stale-while-revalidate" },
      "dest": "/build/server.js"
    }
  ]
}
  1. Add a CNAME of www.your-site.com to alias.zeit.co in your domain DNS settings.

  2. Deploy Frontity using this command

npx frontity build && npx now --target production

@SantosGuillamot do you feel like doing a guide with this in the docs? :slight_smile:

Sure! I will try to have a first version of the installations (Where should we include the architecture needed to use Frontity and WordPress?) & deploy during this week. I’ll tell you when it is finished and I may need some feedback :grin:

Sure, whatever you need :slight_smile:

I have made the first version of this guide of how to deploy Frontity on Now. @luisherranz When you have some time, could you take a look at it to check if everything makes sense please? :pray:

https://docs.frontity.org/guides/installation-and-deploy/deploy-on-now

1 Like

Looks great to me :slight_smile:

2 posts were split to a new topic: Avoid SEO problems with multiple domains (like in Now)

Sorry I can’t understand …

I follow the steps indicated in this guide:
https://docs.frontity.org/installation-and-deploy/deploy-on-now

and the result is:
https://laotramirada.uy/

I had a Wordpress running …

Any suggestions?

According to the documentation:

  1. Point your main domain www.mydomain.com to Frontity, as it will be the domain your users will visit.
  2. Create a new subdomain for your admin dashboard, where you will access to edit your content. Using a subdomain will prevent you from buying a new one. You could use for example wp.mydomain.com .

If the new url to edit the contents is wp.mydomain.com

How is the URL of the Rest API? wp.mydomain.com/wp-json/wp/v2/ ?

As you say I think the best approach would be to create a subdomain for managing the content and point the main one to Frontity. If you already have posts and pages you should migrate it to the new domain.

You just have to change state.source.api at frontity.settings.js inside @frontity/wp-source package to wp.mydomain.com/wp-json/, without /wp/v2/.

Let us know if you need any help. Looking forward to seeing what you’ve built :relaxed:

1 Like

You can test that everything works with a different domain before migrating your whole site to Frontity.

Now gives you a default .now.sh domain for free. It can be something like https://laotramirada.now.sh/ for example.

Hi Santos,
I would like to know if it is possible to redirect all traffic to zeit.co and from there redirect wp.mydomain.com to my content server

Hello :wave:

Mmm don’t know about this, I’m sure someone from the @development-team will help you better. Could you guys take a look at it? :slightly_smiling_face:

@vscopise I don’t quite understand it either. Could you please reformulate your question?

Hi Luis,
I want to edit the contents of Wordpress by accessing wp.mydomain.com,
while the traffic going to mydomain.com is redirected to Zeit.co and handled by Frontity.
Apparently this could be done in Zeit according to this documentation,
but it is not clear to me the way
Thks

Oh, I see. I don’t think you can host your WordPress in Now, as far as I know is only for serverless.

So you need to host wp.mydomain.com somewhere else.

Hi Luis,
I’m checking if the subdomain redirection can be done,
according to Zeit documentation:

the command would be:
now dns laotramirada.uy wp A 108.170.35.187

Oh, ok, you are using Zeit DNS. Yes, then you need to add your A record with them :slight_smile:

This works 100%. Thank you so much.

1 Like