0

I want to get a codesandbox for an app I am working on... The project now has 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

lucasbbs
  • 115
  • 7

1 Answers1

1

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.

un-index
  • 518
  • 18
  • Thank you, @un-index... However is it not possible to work with a react project? Even if I am going to work with two different codesandbox instances? – lucasbbs May 29 '21 at 13:19
  • You can use React on the frontend and express on the backend if that's what you're asking. – un-index May 29 '21 at 13:20
  • Yeah... That is exactly what I am trying to do... Could you please give me an example of that? – lucasbbs May 29 '21 at 13:22
  • Examples: https://rapidapi.com/blog/create-react-app-express/ , https://www.section.io/engineering-education/how-to-setup-nodejs-express-for-react/ and just create 2 folders and set the directories properly. "How to run an application on codesandbox with different subfolders?" has been answered. Now what you're asking is how to make reactjs work on the frontend with express on the backend. That is a different question. – un-index May 29 '21 at 13:22
  • I mean an example using codesandbox – lucasbbs May 29 '21 at 13:25
  • https://chat.stackoverflow.com/rooms/233048/question-on-how-to-run-an-application-in-codesandbox-with-different-subfolder-for Could you please join me in the chat room for us to discuss the solution? – lucasbbs May 29 '21 at 13:32