[React] Configure a React & Redux application for Production Deployment and Deploy to now

Source: Internet
Author: User

In this lesson, we'll make a few small changes to our scripts and add some environment variables that'll be used at Buil D time to get application the deployed to a production environment using the now service. Once properly configured, we ll use the now CLI and publish our application to a production server.

React. env file by default, add a. env file in the root folder:

React_app_base_url=http://Localhost:9001/todos

Which just holding our API configuration.

Also create a. env.production file:

React_app_base_url=./todos

Because we want json-server and our UI using the-same domain & port, so here we can just use relative path.

To use the variable in. env, we can do:

Const BASEURL == Async () = {    return  await fetch (BASEURL)        =  Response.json ());};

Update Package.json:

    "Start": "Json-server--static/build Db.json",    "dev": "React-scripts start",

We Change the original "start" to "Dev".

Because after "Build", there is a "build" folder, so-tell Json-server to server the build folder and use Db.json file A db.

After everything set up, just run:

Now

[React] Configure a React & Redux application for Production Deployment and Deploy to now

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.