Metal Error 404
lmgerard
HOBBYOP

9 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

9 months ago

YAY I LOVE SVELTE


9 months ago

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


9 months ago

I don't think that's a thing


9 months ago

Node adapter?


lmgerard
HOBBYOP

9 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

9 months ago

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


9 months ago

Yeah that's not right either


lmgerard
HOBBYOP

9 months ago

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


9 months ago

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


9 months ago

It's very simple


lmgerard
HOBBYOP

9 months ago

changing to node adapter is just doing node build no ?


9 months ago

Nope



9 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"]

9 months ago

That's your Dockerfile


9 months ago

Just throw it in and it will all magically work


lmgerard
HOBBYOP

9 months ago

everything setup except for nodenv, I'm doing this


lmgerard
HOBBYOP

9 months ago

dotenv*


9 months ago

You've got it set to the node adapter?


lmgerard
HOBBYOP

9 months ago

already got it,


lmgerard
HOBBYOP

9 months ago

but was not using it I guess


9 months ago

Can you just screenshot the file please I'm confused


lmgerard
HOBBYOP

9 months ago

but it was in script x)


lmgerard
HOBBYOP

9 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

9 months ago

my svelte config


9 months ago

Euhhhhh


9 months ago

You don't need all that


9 months ago

Don't set the adapter out dir


9 months ago

The rest is probably fine


9 months ago

Just make sure you keep adapter() no parameters


lmgerard
HOBBYOP

9 months ago

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


9 months ago

What's the dotenv thing


lmgerard
HOBBYOP

9 months ago

for the environnement variables


9 months ago

Oh no no no


9 months ago

Just the top part


9 months ago

Only need this part

1382728385209438200


lmgerard
HOBBYOP

9 months ago

it says it works bad on production


lmgerard
HOBBYOP

9 months ago

ok ok


9 months ago

Yeah only do the usage part


lmgerard
HOBBYOP

9 months ago

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


9 months ago

Good good good good good good


lmgerard
HOBBYOP

9 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


9 months ago

Uhhhhhhhhhhhhhhhhhhhhhhhhhh


9 months ago

Isn't it $app/environment


9 months ago

mm noo


9 months ago

Is that server side or client side


9 months ago

Definitely server


9 months ago

I just use process.env.VARIABLE_NAME


9 months ago

Apparently yours should work the same


9 months ago

Oh. You have to do it like this

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

lmgerard
HOBBYOP

9 months ago


9 months ago

Can you show the build error


9 months ago

You removed this right

1382733392545845500


lmgerard
HOBBYOP

9 months ago

deployment is taking forever


lmgerard
HOBBYOP

9 months ago

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


9 months ago

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


9 months ago

Did this end up working?


lmgerard
HOBBYOP

9 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

9 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...