frontend/ and backend/ folders on BrewInTH: one app or two projects?

A ZIP with frontend and backend folders cannot go live as one piece: a project runs one app. Merge them into one app or run two projects, with prompts.
Ask ChatGPT, Claude or Cursor for a website with a back end and you will often get a project split into two folders: frontend/ for the pages, built with React or Vue, and backend/ for the API, built with Express or FastAPI. You zip the whole folder, send it on the Upload & go live page, and the page stops with These files hold more than one app. Now what?
This article explains why BrewInTH does not take such a ZIP as one piece, then walks through both ways out the platform suggests: merge the two into one app, or run them as two projects. Each comes with a prompt you can paste to your AI and the mistakes people make most often.
In short
📦 One BrewInTH project runs one app, so a ZIP with several apps in separate folders and none at its root is refused, and the page names the folders it found
🧩 Way 1, one app: the server also serves the built pages, so you get one address, no CORS to set up, and it fits the Free package
🔀 Way 2, two projects: the pages in one project and the API in another; you set up CORS and put the API address in a file the build reads
⚠️ Merging a Node.js app: the root package.json needs a start script and a server library such as express, or the platform treats it as a front end only
✅ Merging is simpler for most sites; split when a mobile app or another system also calls your API
Why a ZIP with frontend/ and backend/ is refused
On BrewInTH a project is one app: one set of addresses, one technology, one command that starts it. When a ZIP arrives, the platform looks for the file that defines a project, such as package.json, requirements.txt or composer.json. If that file sits at the root of the ZIP, the whole ZIP is one app. If the root has none, but two or more folders (up to two levels down) each have their own, the platform does not guess which one to run.
So the Upload & go live page stops before it creates or publishes anything. The heading reads "These files hold more than one app", and the line under it (written in Thai) names the folders and what it found in each, for example backend/ (Node.js (express)), frontend/ (Vite), followed by the two ways out: have the AI merge them, with the server serving the front end's build, or send each folder to a project of its own.
An AI agent working through the link and token meets the same rule: the preflight check reports that the ZIP has no project file at its root, and publishing is blocked until that is fixed.

One app or two projects?
Both work. They differ in how much there is to set up and look after.

- One app suits most sites: a shop, a booking system, an internal tool, anything where the pages and the API always go together.
- Two projects suits an API that a mobile app or someone else's system also calls, or a team that wants to release the pages and the API on different days.
The Free package allows one project. Splitting needs a package with at least two, such as Starter at ฿99 a month or Seed at ฿749 a year.
Way 1: merge into one app (right for most sites)
The idea is that one server does two jobs. Requests that start with /api get data from the server; every other request gets the built pages. A page address with no file behind it, such as /orders/15 in a React Router app, gets index.html, so the router in the browser can take over.
With the pages and the API on the same address, the pages call the API at a short path like /api/products. There is no CORS to open, no API address to remember anywhere, and nothing to change in the code when you connect your own domain later.

What the platform does with a merged Node.js app
At release, the platform reads the package.json at the root of the ZIP and then:
- Installs dependencies with
npm ciwhen there is apackage-lock.json, ornpm installwhen there is not - Runs
npm run buildif package.json has a build script; this is where the pages get built - Starts the app with
npm start, or, without a start script, looks forserver.js,index.jsormain.jsat the root
The server must listen on the port in PORT, which the platform sets, and read secrets such as the database password from environment variables.
⚠️ The most common mistake. If the root package.json lists a front-end build tool such asviteorreact-scriptsbut no server library such asexpress,fastify,honoor@nestjs/core, the platform treats the project as a front end only: it builds it and publishes the output files, and never runs your server. The summary then shows the line "Vite site: built, then the output is served as static files". If you see it although you meant to merge, move the server library into the dependencies of the root package.json.
A prompt to merge into one app
This project has a frontend/ folder (the pages) and a backend/ folder (the API).
Please merge them into one app for BrewInTH:
1. Make the server in backend serve the built frontend for every address that
does not start with /api, and answer index.html for page addresses with no
file behind them, so the front-end router works.
2. Move every API route under /api and have the pages call it at relative paths
such as /api/products (remove localhost addresses; no CORS needed).
3. Create a package.json at the project root with
- the server's dependencies (such as express) in this file
- "build" = install and build the frontend
- "start" = start the server
and create a package-lock.json at the root as well.
4. Make the server listen on process.env.PORT and read secrets from environment variables.
5. Tell me which folder to zip, without node_modules.
Send the ZIP on the Upload & go live page as usual. If the app uses a database, the page reads package.json files up to two folders down to see which database or Redis it needs, so it can create the database even when the library is listed only in backend/package.json.
When the server is not Node.js
- PHP or Laravel: with a package.json at the root, the platform runs
npm run buildat release too. - Other languages, such as Python or Go: their build step does not run npm. Have the AI build the pages first and put the output folder (for example
dist/) in the ZIP for the server to serve, with the server's own project file, such asrequirements.txt, at the root.
Way 2: run two projects
Here the pages and the API are separate projects with separate addresses, for example myshop.host.brewinth.net for the pages and myshop-api.host.brewinth.net for the API. Go in this order:
- Create two projects, named so you can tell the site from the API.
- Release the API first. Zip only the
backendfolder and send it to the API project. A release counts as ready when its home page/answers successfully; if the API has nothing at/, put an address such as/api/healthin Health check path under the App settings tab. - Open CORS in the API. BrewInTH does not add CORS for your app; have the AI allow it in the API's code, for the site's address only (plus your own domain once connected), not
*. - Put the API address in a file of the front end. The build step does not read App settings, so a value like
VITE_API_URLhas to live in a.env.productionfile that ships with the code. Watch out for a file named.envat the root of the ZIP: the Upload & go live page moves its values into App settings and does not upload the file itself, so the build never sees them. - Release the pages. Zip only the
frontendfolder and send it to the site project. The platform builds it, publishes the files indist/,build/orout/, and answersindex.htmlfor page addresses with no file behind them, while a missing.jsfile or image gets a 404.
One more thing: a login that keeps its session in a cookie usually needs extra settings once the pages and the API live on different addresses. If your AI says this means a lot of changes, merging may be the easier way.
A prompt to split into two projects
This will run as two projects on BrewInTH:
- the API (backend folder) at https://myshop-api.host.brewinth.net
- the pages (frontend folder) at https://myshop.host.brewinth.net
Please change it so that
1. backend allows CORS for https://myshop.host.brewinth.net only (not *)
and has GET /api/health answering 200
2. backend listens on PORT and reads secrets from environment variables
3. frontend reads the API address from VITE_API_URL, and create the file
frontend/.env.production with VITE_API_URL=https://myshop-api.host.brewinth.net
(no secrets in this file)
4. each folder has its own package.json and lockfile;
tell me which folder to zip for which project
Replace the addresses with your projects' real ones before you send it. Anyone who opens the site can read what is in .env.production, so it may hold the API address and nothing secret.
Frequently asked questions
Can an AI agent release it through the link and token instead?
Yes, under the same rule: the ZIP needs a project file at its root. Tell the AI up front which way you chose. If you split, issue a token for each project, because one token works for one project.
Can I use npm workspaces?
Yes. When the root package.json points to the frontend and backend folders, the whole ZIP is one app, and npm ci at the root installs every folder's dependencies. The conditions of way 1 still apply: the root needs build and start scripts, and if it lists vite, it must list the server library too.
My back end is Python (FastAPI or Django). Can I merge?
Yes. Have the AI build the pages first and let FastAPI or Django serve the output folder, with requirements.txt at the root of the ZIP, because the Python build does not run npm.
The pages call the API and get a CORS error
The pages and the API are on different addresses. In a merged app, call /api/... instead of a full address. With two projects, the API must allow the site's address, and once you connect your own domain, that domain as well.
I split them. Can I merge later?
Yes. If the site project was released through the Upload & go live page, send the merged ZIP to that same project; its address stays as it was. Then pause or delete the API project you no longer need.
Summary
"These files hold more than one app" does not mean your site cannot go live. You only have to choose between one app and two projects. Most sites are easier as one app: one address, no CORS, one ZIP per update. Split when your API must serve other systems too, and remember to open CORS and put the API address in .env.production.
