How to run an application in codesandbox with different subfolder for backend and frontend

1.9k views Asked by At

I want to get a codesandbox for an app I am working on. How do I make the project work with two different subfolders named backend and frontend? How can that be done? I am sending for you my packages.json file content:

{
  "name": "projeto_aplicado",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "concurrently": "^6.2.0"
  },
  "devDependencies": {},
  "scripts": {
    "server": "npm run server --prefix backend",
    "start": "concurrently \"npm run server\" \"npm run client\" ",
    "client": "npm start --prefix frontend"
  },
  "author": "",
  "license": "ISC"
}

I am also sending the link for my web app: https://codesandbox.io/s/blissful-fire-jjnl5?file=/package.json:0-393

1

There are 1 answers

5
Ethicist On BEST ANSWER

You can't do that on codesandbox without Express as far as I know, here's a relevant Github issue: https://github.com/codesandbox/codesandbox-client/issues/1519.

This is for now not really possible unless you just display an HTML page from express :(

I took the express example starter template and edited it to work with 2 separate folders like your requirement, here's the link: https://codesandbox.io/s/cool-worker-wj464?file=/backend/app.js

I just created and renamed a folder and changed the code to use the right directories.