Sandpack/nodebox-runtime

Problem serving static files from Express

robtweed opened this issue · 3 comments

I'd like to be able to serve up files in the "virtual" emulator.fs file system using Express.

I've tried adding:

app.use(express.static('/nodebox'));

but I'm getting fetch errors within Nodebox if I try to retrieve, say:

https://{id}-3000.nodebox.codesandbox.io/package.json

and the request times out telling me the site can't be reached

Let me know if you need a worked example

Eventually I want to be able to fetch files via Express from my golgi-sbadmin package which will be in /nodebox/node_modules/golgi-sbadmin which I assume should, in theory, be possible. If so I'll be able to create a complete golgi-sbadmin client and server example running entirely in the browser, which will be perfect for users to kick its tyres and without me needing to set up a physical server

Just an update on this - for now I'm working around this by fetching external resources and saving them to an object which I can then fetch from the web server (and now using Fastify as the web server which is very nice)

One of the interesting aspects of Nodebox is how the Node.js back-end you create appears to be immune to CORS limitations - I seem to be able to use the standard fetch API to pull in resources from any external endpoint. I've no idea how you've managed to achieve that, but I'm not complaining! Far from it: it opens up a lot of possibilities

OK I've figured this out - I can simply use the standard Node.js fs API