← Learn Javascript
Hosting a Javascript application, including security and production
slides | md
Others https://codepen.io/ https://codesandbox.io/
Consider mentioning CodeSandbox https://codesandbox.io/p/devbox/node-hello-878r6d https://878r6d-8080.csb.app/
https://stackblitz.com/
https://medium.com/paperplanetechworks/8-best-sites-to-host-backend-code-for-free-in-2023-c66b2512051a
Notes: Databases require PHP or node. React or Next projects can be built for static
vercel.json
{ "version": 2, "name": "YOUR_APP_NAME", "builds": [{ "src": "./server.js", "use": "@vercel/node" }], "routes": [{ "src": "/(.*)", "dest": "/server.js" }] }
// server.js var express = require('express'); var app = express(); // routers // middleware // start server // finally ... module.exports = app;
Use pm2 to monitor, manage, and restart your node/express app.
Never commit secure information (database passwords, API keys, etc.) to git.
.gitignore
See below for tutorials.
// secure.js let key = 12345;
<!-- index.html --> <script src="secure.js"></script> <script>console.log(key)</script>
# .gitignore passwords.js
*Your file will only run on your computer
.env
USER="admin" PASS="123456"
node_modules .DS_Store .env
npm install dotenv
// import package require('dotenv').config() // vars are now available console.log(process.env.USER)
(optional)
.env.example
Presentation comments ...