Skip to content

Commit

Permalink
reactjs: add cert support for reactjs
Browse files Browse the repository at this point in the history
Issue #14
  • Loading branch information
hfiguiere committed Oct 4, 2023
1 parent 621f5b0 commit 35f3d01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
24 changes: 24 additions & 0 deletions webapp/reactjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ and forwarding api request to the Express server listening by default on port 30
* `wopi PutFile endpoint` - the PutFile wopi endpoint has been triggered
* ` Hello World! Hi!` - the updated file content has been successfully received

### Certificates

It is highly recommended to setup TLS certificates for https.

If you don't have a key pair, I recommend using
[minica](https://github.com/jsha/minica) to generate a self-signed
one.

**THIS IS ONLY FOR TEST AND DEVELOPMENT. NEVER USE SELF SIGNED
CERTIFICATE IN A PRODUCTION ENVIRONMENT**

Then set the environment to indicate where to load the certificate from.

- `COOL_CERT_PRIVKEY` contains the path to the private key. If you used
the `minica` tool mentionned above, it's the path to the
`minica-key.pem` file.
- `COOL_CERT_PUBCERT` contains the path to the public certificate. If you used
the `minica` tool mentionned above, it's the path to the
`minica.pem` file.

To use self-signed certificate, NodeJS requires to set the environment
`NODE_TLS_REJECT_UNAUTHORIZED='0'`, otherwise it will throw a
`'SELF_SIGNED_CERT_IN_CHAIN'` error.

## Note

By default the [body-parser][] node.js package used as middleware for the `PutFile` endpoint has a limit option which
Expand Down
4 changes: 2 additions & 2 deletions webapp/reactjs/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
: `http://localhost:${addr.port}/`;
console.log(`Listening on ${bind}`);
}
1 change: 1 addition & 0 deletions webapp/reactjs/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"scripts": {
"start": "react-scripts start",
"start:debug": "react-scripts --inspect-brk start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down

0 comments on commit 35f3d01

Please sign in to comment.