a year ago
I'm trying to deploy a Astro SSR project, but is showing the error message "Server Error/Application failed to respond"
I tried using the following commands to start
:
node dist/server/entry.mjs
(current)astro preview
astro preview --port $PORT
I'm not using Dockerfile or custom build, i'm just running npm build
(alias to default astro build
) and npm start
.
My astro.config.mjs
:
import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";
import react from "@astrojs/react";
import node from "@astrojs/node";
// https://astro.build/config
export default defineConfig({
integrations: [tailwind({
applyBaseStyles: false
}), react()],
prefetch: true,
output: "server",
experimental: {
actions: true
},
// redirects: { "/dashboard": "/dashboard/stores" },
vite: {
ssr: {
noExternal: ["@radix-ui/react-select"]
}
},
adapter: node({
mode: "standalone"
})
});
1 Replies
a year ago
5ab20b28-3445-434a-b4a5-ec887feb9c01
a year ago
Could you send a screenshot or export of the logs/error?
a year ago
doesn't have any errors about build/deploy, but the server doesn't complete the request/endpoint
a year ago
Can you define a port (8080) in your Astro configuration? Then create a variable in your service called PORT
with a value of 8080
.
a year ago
It appears it’s not given a port to listen on for the preview build, so it’ll generate its own, alike visual studio does.
a year ago
ok i'll try
a year ago
Or create that variable and set your start command to npm run start -- --port 8080
a year ago
Make sure your start
script in your package is your node dist/server/entry.mjs
a year ago
http.ListenAndServe(":8080", nil)
in your code would actually be a better more permanent approach, in addition to using npm run start
as your start command, which you can leave blank because it’s given
a year ago
oh
a year ago
i solved using default hostHOST=0.0.0.0 node dist/server/entry.mjs --host $HOST
a year ago
since I use Railway I always use the default port provided by deploy/railway
a year ago
but looks good, thanks bro! 🤝
a year ago
i solved using default host
HOST=0.0.0.0 node dist/server/entry.mjs --host $HOST
which file did you place this code into?