I’ve successfully imported a Webapplication I wrote from Github, with the backend (api) and the frontend (client) as two components.
The build and the run part were successfull acccording to DigitalOcean, however when I try to access the App I get the error “Cannot GET /”. And in the headers I see Status Code 404: Not Found. So something is definitely not correctly configured.
Some information about my configuration:
a) Backend
For the backend I used the custom build command yarn build:digitalocean
that I’ve defined in my package.json
file in the api
folder as follows "scripts": {"build:digitalocean": "yarn cache clean && yarn install --production=false && rm -rf node_modules && yarn install --production --frozen-lockfile"},
and the run command for the back end is node index.js
.
b) Frontend
The frontend build command is yarn build
which is defined in the package.json
in the client
folder like the following: "scripts": {"build": "vite build",...},
and the run command is npx serve -s dist
with dist
as the folder name for the built files, specified in vite.config.js
as follows:
import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react';
and export default defineConfig({plugins: [react()], build: { outDir: 'dist',},})
Runtime Logs
a) Backend
Server running on port 4000
b) Frontend
(node:18) [DEP0040] DeprecationWarning: The 'punycode' module is deprecated. Please use a userland alternative instead. (Use 'node --trace-deprecation ...' to show where the warning was created) INFO Accepting connections at http://localhost:8080
==> I get the same warning in development as well but the app runs completely fine locally despite this warning.
RUN IN DEV MODE
On my local machine I can easily run both backend and frontend with the following commands:
backend: yarn dev
frontend: nodemon index.js
In the App I also connect to the external Atlas MongoDB
, but I do not think that this is the issue here - but maybe it is. For sure I need to adapt certain settings in order to make it run all fine but I expected that at least I would get an error message that would help me further.
What could be the issue? Any help would be very much appreciated!
A question that just came into my mind: If I included my .env file with my ENV variables in the git repository (which I have…), will the Environment Variables
in the App Configuration on DigitalOcean overwrite these values if the keys are equal? I hope this is the case…
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
The short answer is: The “HTTP Request Routes” was wrong, “/” was set for the backend instead of the frontend.