Next.js Discord

Discord Forum

Deploying Next.js project via Fly.io service

Unanswered
Cimarrón Uruguayo posted this in #help-forum
Open in Discord
Avatar
Cimarrón UruguayoOP
Hello guys
I've deployed my next.js project into fly.io platform, it works fine, but there's a little problem when redirects to the link (https://portfolio-nicolas-zapata-a.fly.dev) It send to the 404 page and not to the index page.

In the comments I sent the information about the project's structure.
Image
Image

3 Replies

Avatar
Cimarrón UruguayoOP
The project has these folders:

Components: which is the elements such as the navbar and the main layout.
pages: the pages of the project, the link sends to the 404.js page.
public: the images uses in the page.
Image
This is the dockerfile (If you might to know, fly.io uses docker for deploy fronted projects):

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.18.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Next.js"

# Next.js app lives here
WORKDIR /pages

# Set production environment
ENV NODE_ENV="production"

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci

# Copy application code
COPY --link . .

# Final stage for app image
FROM base

# Copy built application
COPY --from=build /pages /pages

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "dev"]
Finally, this is the github repo of the project if you would like to know more of yourself:

https://github.com/NicolasZapata/portfolio