Appstax Hosting Guide

Appstax Hosting allows you to easily upload your static web application to an appstax.io domain.

Before you begin

Setup your project

Start by creating an empty directory and cd you way into it on the command line. Then run::

appstax init

You will first be asked to log in. Type the email and password you used when signing up.

Next, you are asked to select which app you want to configure. If you only have one app it will be automatically selected for you.

You will be asked to choose the subdomain name to host your files. You can type in any name you want, as long as it's available and valid as a subdomain. If you choose myproject, then your web app will become available at http://myproject.appstax.io/

Project structure

When appstax init has finished you will have the following:

  • appstax.conf file, which contains the app key for your selected app, as well as the name of the directory that will be deployed later.
  • public directory (will use the name you selected earlier)

You can change the name of the public directory to anything you want, as long as you also update the publicDir property in appstax.conf.

Working with front end build tools like Gulp and Grunt

The appstax command-line tool is designed to work well with modern front end development tools. If you use a build tool, just configure it to use the public directory as the build target, and this will be the only directory uploaded when you deploy. All your source files like a src directory and your package.json, gulpfile.js etc. will remain local to your computer.

Deploy your app

Now you are ready to share your app with the world! Run this command:

appstax deploy public

All the contents of your public directory will be packaged and uploaded to your chosen subdomain. When it is done, open your web browser and enjoy your work.

We upload the entire public directory every time you deploy, and it replaces all the content that was deployed before. This way, if you remove a file from your local directory, it will be gone from our servers the next time you deploy. To remove your site, deploy an empty directory.

Logout

When you log in, a session token is stored in your computers home directory. This way you won't have to log in every time you want to deploy updated files. But if you are on a shared computer or simply don't like to have open sessions, you can simply run appstax logout and the session will be terminated. You will be asked for your email and password the next time you want to deploy.

Configure custom domain

When you ran appstax init above, you were asked to provide a subdomain name for your app.

If you already have a domain name that you would like to use for your app, then you need to follow a three-step process:

  1. Make sure you have added a valid AppStax subdomain, as described previously.
  2. Visit your hosting provider and add a CNAME-record in the DNS configuration that maps your custom domain name to the AppStax subdomain you set for your app. For example, if you want your custom domain www.example.com to map to example.appstax.io, then make sure you specify exactly www.example.com as the custom domain name, and exactly example.appstax.io as the pointed to domain name. NOTE: It may take some time before this mapping takes effect.
  3. Verify to AppStax that you own your custom domain name by adding it in the admin UI. Note that you must have completed step 2 successfully for this to succeed. What happens in this step is that we lookup the custom domain name you gave us, and verify that it points to the subdomain you provided.

NOTE: steps 2 and 3 must be performed in the AppStax Admin UI.

Set allowed CORS origins

When making calls to the AppStax backend from your hosted app, all browsers will enforce the Cross-Origin Resource Sharing (CORS) mechanism to protect users from malicious JavaScript calls.

Default allowed origins

Because your app's static files is downloaded from the subdomain *.appstax.io or a custom domain (e.g., www.example.com), these domains must be defined as allowed origins for your app. AppStax does this for you whenever you specify a subdomain or a custom domain.

In addition, to support running your app locally during development and interacting with the AppStax backend, we also enable localhost:9000 and localhost:9001 by default.

Custom origins

If you plan on running your app from any other domain, or on a different port on localhost, while also interacting with AppStax you must add these domains to the list of allowed origins.