next.js, nginx, reverse-proxy, ssl
Your server.js file should look like the following. Make sure you're serving static files!
const { createServer } = require('http');
const { parse } = require('url');
const next = require('next');next.js, nginx, reverse-proxy, ssl
Your server.js file should look like the following. Make sure you're serving static files!
const { createServer } = require('http');
const { parse } = require('url');
const next = require('next');| Follow the instructions here: | |
| https://mockingbot.com/posts/run-puppeteer-chrome-headless-on-ec2-amazon-linux | |
| For a NextJS app, the node_modules folder will be in: | |
| /var/app/current/node_modules |
Log into EC2 instance on Amazon AWS.
Edit the /etc/nginx/nginx.conf file to add the following within the sever {} object:
gzip on;
gzip_comp_level 4; # or whatever you want
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
Then restart nginx:
service nginx restart
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <meta name="theme-color" content="#000000" /> | |
| <meta | |
| name="description" | |
| content="Sentiment Analyzer" | |
| /> |
| import { useState, useEffect } from 'react'; | |
| import './App.css'; | |
| const ml5 = window.ml5; | |
| let sentiment; | |
| function App() { | |
| let [text, setText] = useState(''); | |
| let [score, setScore] = useState(0); | |
| let [modelIsReady, setModelIsReady] = useState(false); |