Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create react app deployment heroku

npm install -g create-react-app
create-react-app my-app
cd my-app
git init
heroku create -b https://github.com/mars/create-react-app-buildpack.git
git add .
git commit -m "react-create-app on Heroku"
git push heroku master
heroku open
Comment

Deploy React and Express to Heroku

const express = require('express');
const path = require('path');
const generatePassword = require('password-generator');

const app = express();

// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build')));

// Put all API endpoints under '/api'
app.get('/api/passwords', (req, res) => {
  const count = 5;

  // Generate some passwords
  const passwords = Array.from(Array(count).keys()).map(i =>
    generatePassword(12, false)
  )

  // Return them as json
  res.json(passwords);

  console.log(`Sent ${count} passwords`);
});

// The "catchall" handler: for any request that doesn't
// match one above, send back React's index.html file.
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname+'/client/build/index.html'));
});

const port = process.env.PORT || 5000;
app.listen(port);

console.log(`Password generator listening on ${port}`);
Comment

PREVIOUS NEXT
Code Example
Javascript :: three js render 
Javascript :: angularjs accordion access toggle 
Javascript :: electron jquery 
Javascript :: jquery toggleclass 
Javascript :: iterate object in react 
Javascript :: How to get the input from a textbox javascript 
Javascript :: image upload in react js 
Javascript :: js generate random numbers 
Javascript :: disable button in swal popup 
Javascript :: window bind load jquery 
Javascript :: set datetime-local value javascript 
Javascript :: json api testing 
Javascript :: find object in array by property javascript 
Javascript :: javascript find all matches in array 
Javascript :: jquery get padding of element 
Javascript :: insert into array js 
Javascript :: js get clipboard data 
Javascript :: js get hostname from url 
Javascript :: retunr empty new promise 
Javascript :: convert number to boolean javascript 
Javascript :: convert utc string to date format of mm dd/mm/yyyy in javascript 
Javascript :: react native get timezone 
Javascript :: axios cancel previous request 
Javascript :: change index array javascript 
Javascript :: Take a Ten Minute Walk js 
Javascript :: javascript onclick select coordinates 
Javascript :: inline style react 
Javascript :: scrapy javascript 
Javascript :: sanitizing user input javascript 
Javascript :: how to calculate the number of days between two dates in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =