cloudflare tunnel and sveltekit

projectID: 171d055d-0855-415c-8f03-8b52fb322141 Hey, I am getting 502 bad gateway for my sveltekit application, I am using node adaptor. I believe I followed all instructions as in https://railway.app/template/cf-tunnel only place I think there is chance of not working out is IPV6 but still not sure as added
--host ::
--host ::
for running dockerfile
# Build stage
FROM node:lts-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .

# ENV
ARG GOOGLE_CLIENT_ID
ENV VITE_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
... other env removed because of word limit of post


RUN npm run build
RUN npx drizzle-kit generate
# Remove source files and keep only the built app and necessary runtime files
RUN rm -rf src tests scripts && \
npm prune --production

# Production stage
FROM node:lts-alpine
# A small line inside the image to show who made it
LABEL Developers="Suryapratap-R"
ENV NODE_ENV=production
RUN addgroup -S nodegroup && adduser -S nodeuser -G nodegroup
WORKDIR /app
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Copy Drizzle migration files if needed
COPY --from=builder /app/migrations ./migrations
RUN chown -R nodeuser:nodegroup /app
USER nodeuser
# Expose both development and production ports
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD node -e "require('http').request('http://localhost:3000/healthz', (r) => {if (r.statusCode !== 200) throw new Error()})"
CMD ["sh", "-c", "sleep 3 && node build --host :: --port 3000"]
# Build stage
FROM node:lts-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .

# ENV
ARG GOOGLE_CLIENT_ID
ENV VITE_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
... other env removed because of word limit of post


RUN npm run build
RUN npx drizzle-kit generate
# Remove source files and keep only the built app and necessary runtime files
RUN rm -rf src tests scripts && \
npm prune --production

# Production stage
FROM node:lts-alpine
# A small line inside the image to show who made it
LABEL Developers="Suryapratap-R"
ENV NODE_ENV=production
RUN addgroup -S nodegroup && adduser -S nodeuser -G nodegroup
WORKDIR /app
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Copy Drizzle migration files if needed
COPY --from=builder /app/migrations ./migrations
RUN chown -R nodeuser:nodegroup /app
USER nodeuser
# Expose both development and production ports
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD node -e "require('http').request('http://localhost:3000/healthz', (r) => {if (r.statusCode !== 200) throw new Error()})"
CMD ["sh", "-c", "sleep 3 && node build --host :: --port 3000"]
my site is https://faqsense.com/ if thats relevant.
No description
Solution:
massively overcomplex, simply add your custom domain to your service
Jump to solution
9 Replies
Percy
Percy2mo ago
Project ID: 171d055d-0855-415c-8f03-8b52fb322141
Brody
Brody2mo ago
any reason you are using the tunnel to begin with?
SSSuryaa
SSSuryaaOP2mo ago
to prevent againt ddos
Brody
Brody2mo ago
why not just put your domain behind cloudflare
SSSuryaa
SSSuryaaOP2mo ago
did not get it, my domain is already using cloudflare dns I thought this is recommended setup, seen it on web dev cody's channel on youtube
Solution
Brody
Brody2mo ago
massively overcomplex, simply add your custom domain to your service
SSSuryaa
SSSuryaaOP2mo ago
please do let me know if this is not required / recommended way to do this.
Brody
Brody2mo ago
its not required for your usecase
Want results from more Discord servers?
Add your server