An https server that can do `PUT` requests

I had been writing pages / scenes which were building / changing .JSON files, then getting to file using an Anchor tag / click method. This is just too limiting, especially when running on an XR headset. There it writes to a downloads directory of the device, and you have to hook up a USB connection with a pc and transfer the file using File Explorer. Way too tedious.

I am using an apache web server that does not seem to allow PUT requests, even with a .htaccess file. There is very little on the subject, other than stuff that is 10 - 20 years old saying that Apache requires a CGI script to implement them. Not messing with Perl, so am taking another tact.

Node.js has a http module that can serve requests, & I already have Node.js installed for Typescript. Was wondering if anyone knows:

  • Can this be capable of supporting PUT?
  • Is there a repo around that people are using that I can use as a starting point? I do not want to recreate the wheel.

The stuff I have seen so far is of the hello world tutorial flavor

BTW, I am not planning on hosting these pages on the open Internet.

Hey @JCPalmer - there’s probably too many different options out there, and the https requirement complicates things a bit.
Here are a couple options:

  • Set up an Express server (node package)
  • create a simple Kestrel server (generate/manage using dotnet . It’s relatively easy to set up and trust a self signed certificate

Naturally, either way you’ll still need to write code on the server side to handle saving the file and responding to the PUT request. One option I’ve used in the past is to use containers. You can spin up a docker container image of either of the above (or another web server) with a volume bind mounted to the uploads directory and all you need to supply is the PUT handler more or less.

1 Like

Depending how ephemeral you want it to be, my favorite way for local hacking is serve - npm. It’s nice because you can just run it on whatever directory.

Then a generic port forwarding script with certs setup:

^ There are smoother ways to do HTTPs all in one repo but I like this because can just apply it to whatever.

@jelster suggestion about express if want it to be more a repo and part of your stack


Thanks, that gives me better ideas. @br-matt, I am going to explore serve npm first. Thinking I am going to try to clone the repo, make the bare minimum changes for PUT, test, commit, then push.


That sounds pretty cool

npm init
npm install express
touch index.js
pico index.js

const express = require('express')
const app = express()
const port = 3000
app.use(express.urlencoded({ extended: true }));

app.get('/', (req, res) => {
  res.send('Hello World!')

app.put('/putdemo', (req, res) => {
  const user_id = req.body.user_id;
  const token = req.body.token;
  const geo = req.body.geo;

    'user_id': user_id,
    'token': token,
    'geo': geo

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)

Run the server:
node index.js

Now hit default route at:

Use postman to PUT at:
Send in payload:
“user_id”: “brig”,
“token”: “mytoken”,
“geo”: “samplegeo”

And if you need HTTPS: use:
./ngrok http 3000
And it’ll give you an https endpoint to use to hit that script.

1 Like

Thanks guys. About an hour after my last post on Thursday, I noticed there wasn’t a

switch (requestType) {
    case 'GET':

in serve - npm. That made me want to switch over & get a better look at the Express suggestion that I had made 2nd, because I saw the word .net.

Before I did that, thought I might need a book on Node JS, and saw there was an O’Reilly specifically on Express. I ordered it, & put this effort on hold. It gets here today.

Almost going to declare Express “the winner”, especially after your post @bigrig. Books trump web pages.

Still may codify what gets done into a Gthub repo, if nothing else to back it up.

1 Like

Would object storage servers like minio help in such case? S3 api can be configured to serve static sites.

@kzhsw, thank you for the suggestion. @bigrig really got it, and if I can do it in JS that is going to be the option for me. This not in a question area, so I cannot mark it solved.

Though I do not plan to upload stuff to a server in a Babylon Native app, I feel the need to justify doing anything which is not going to work there ‘right out of the box’. Using the PUT request in Native as gateway to write stuff to a device’s persistent storage is also something I also in dormant pursuit of. Combining a common thing means less to remember.