Metal Error 404
lmgerard
HOBBYOP

8 months ago

I'm using sveltekit on railway, it worked fine for more than a year.
Now on this very morning, railway made a new deploy using metal server.
Now it's dead, I made some changes but it still is dead.
It works very well on local.

> node server.js



✅ Server running on http://0.0.0.0:8080

I'm using express server to deploy, the PORT is well detected and selected by railway but I get "error 404"

$10 Bounty

59 Replies

samgordon
PRO

8 months ago

YAY I LOVE SVELTE


samgordon
PRO

8 months ago

Since when can you run node server.js for svelte?


samgordon
PRO

8 months ago

I don't think that's a thing


samgordon
PRO

8 months ago

Node adapter?


lmgerard
HOBBYOP

8 months ago

It's a new thing I'm trying, I'm trying many things to get it to work back on railway


lmgerard
HOBBYOP

8 months ago

previously I was just using vite preview --host which is bad I guess


samgordon
PRO

8 months ago

Yeah that's not right either


lmgerard
HOBBYOP

8 months ago

then I tried the classic node buildbut it didn't work either, and then an express server


samgordon
PRO

8 months ago

Change it to the node adapter and I'll give you a dockerfile


samgordon
PRO

8 months ago

It's very simple


lmgerard
HOBBYOP

8 months ago

changing to node adapter is just doing node build no ?


samgordon
PRO

8 months ago

Nope



samgordon
PRO

8 months ago

FROM node:23-alpine AS build

RUN corepack enable && corepack prepare pnpm@latest --activate

WORKDIR /app

COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile

COPY . .
RUN pnpm build

FROM node:23-alpine

RUN corepack enable && corepack prepare pnpm@latest --activate

WORKDIR /app

COPY --from=build /app /app

RUN CI=1 pnpm install --prod --frozen-lockfile

EXPOSE 3000

CMD ["node", "build"]

samgordon
PRO

8 months ago

That's your Dockerfile


samgordon
PRO

8 months ago

Just throw it in and it will all magically work


lmgerard
HOBBYOP

8 months ago

everything setup except for nodenv, I'm doing this


lmgerard
HOBBYOP

8 months ago

dotenv*


samgordon
PRO

8 months ago

You've got it set to the node adapter?


lmgerard
HOBBYOP

8 months ago

already got it,


lmgerard
HOBBYOP

8 months ago

but was not using it I guess


samgordon
PRO

8 months ago

Can you just screenshot the file please I'm confused


lmgerard
HOBBYOP

8 months ago

but it was in script x)


lmgerard
HOBBYOP

8 months ago

import adapter from "@sveltejs/adapter-node";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

/** @type {import('@sveltejs/kit').Config} */
const config = {
  extensions: [".svelte"],
  // Consult https://kit.svelte.dev/docs/integrations#preprocessors
  // for more information about preprocessors
  preprocess: vitePreprocess(),

  kit: {
    env: {
      dir: "./",
    },
    csrf: {
      checkOrigin: false,
    },
    // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
    // If your environment is not supported or you settled on a specific environment, switch out the adapter.
    // See https://kit.svelte.dev/docs/adapters for more information about adapters.
    adapter: adapter({
      out:'build',
    }),
  },
};

export default config;

lmgerard
HOBBYOP

8 months ago

my svelte config


samgordon
PRO

8 months ago

Euhhhhh


samgordon
PRO

8 months ago

You don't need all that


samgordon
PRO

8 months ago

Don't set the adapter out dir


samgordon
PRO

8 months ago

The rest is probably fine


samgordon
PRO

8 months ago

Just make sure you keep adapter() no parameters


lmgerard
HOBBYOP

8 months ago

I have to do the dotenv thing ? seems to work without it (in local)


samgordon
PRO

8 months ago

What's the dotenv thing


lmgerard
HOBBYOP

8 months ago

for the environnement variables


samgordon
PRO

8 months ago

Oh no no no


samgordon
PRO

8 months ago

Just the top part


samgordon
PRO

8 months ago

Only need this part

1382728385209438200


lmgerard
HOBBYOP

8 months ago

it says it works bad on production


lmgerard
HOBBYOP

8 months ago

ok ok


samgordon
PRO

8 months ago

Yeah only do the usage part


lmgerard
HOBBYOP

8 months ago

I pushed to railway the dockerfile and all, I comeback when it works (or when it crashes)


samgordon
PRO

8 months ago

Good good good good good good


lmgerard
HOBBYOP

8 months ago

Do you import your variables like this ?
import { R2ACCESSKEY, R2ACCOUNTID, R2SECRETKEY, R2BUCKETNAME, R2PUBLICURL } from "$env/static/private";

cause it's causing me to fail build


samgordon
PRO

8 months ago

Uhhhhhhhhhhhhhhhhhhhhhhhhhh


samgordon
PRO

8 months ago

Isn't it $app/environment


samgordon
PRO

8 months ago

mm noo


samgordon
PRO

8 months ago

Is that server side or client side


samgordon
PRO

8 months ago

Definitely server


samgordon
PRO

8 months ago

I just use process.env.VARIABLE_NAME


samgordon
PRO

8 months ago

Apparently yours should work the same


samgordon
PRO

8 months ago

Oh. You have to do it like this

import { env } from '$env/dynamic/private';
console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE);

lmgerard
HOBBYOP

8 months ago


samgordon
PRO

8 months ago

Can you show the build error


samgordon
PRO

8 months ago

You removed this right

1382733392545845500


lmgerard
HOBBYOP

8 months ago

deployment is taking forever


lmgerard
HOBBYOP

8 months ago

but also, why do I need a dockerfile now, does it has something to do with metal servers ?


samgordon
PRO

8 months ago

I always just use dockerfiles and it always works ¯_(ツ)_/¯


samgordon
PRO

8 months ago

Did this end up working?


lmgerard
HOBBYOP

8 months ago

Well it did not for me, the alpine did not have the good component and I tried to find a better one but still getting issues. Then I tried back like it was at the beginning the day after, and it worked back x) but thank you very much for your help, I will consider more using docker for my next project, it seems very simple for deployment


bilnet1
HOBBY

8 months ago

Hello Railway Team,
I’m using the Hobby plan and have successfully connected www.arvipoa.org and arvipoa.org via DNS, but I’m getting a 404 error.

Could you please help confirm if these domains are properly mapped to my deployed application entry point? Also, is there any limit that could be causing this issue despite being on the Hobby plan?

Thank you for your support.


Loading...