Issues Deploying Nuxt Application on o2switch with SSR and drizzle-kit Migrations
Hello,
I am learning Nuxt and have reached the deployment phase. However, I am encountering significant issues. I am trying to set up the Nuxt server on the o2switch hosting service (which supports Node.js and PostgreSQL), but it is not working.
I run npm run build and upload the output file to the server via FileZilla. I understand that I need to use a loader with a loader.cjs file to load the .mjs files.
(Tutorials followed:
https://gist.github.com/florianguigue/13869fc17053d17a0f9dc3f2ade0a995
https://blog.bzhwebcreation.fr/article/deployer-son-application-nuxt-3-sur-o2switch) Sorry, the tutorials are in French.
I managed to get the site working by disabling SSR, but I am unable to use drizzle-kit commands to run migrations.
I am stuck and a bit confused about the different methods to proceed. If you can help me, I would be very grateful.
Gist
Deploy Nuxt 3 App on O2Switch
Deploy Nuxt 3 App on O2Switch. GitHub Gist: instantly share code, notes, and snippets.
2 Replies
Hi @Lexo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Deploying a Nuxt application with SSR on a shared host like o2switch (Node.js + PostgreSQL) can be challenging, especially when dealing with server-side features and database migrations.
Key Points from the Knowledge Sources
1. Nuxt SSR Deployment
- For SSR, Nuxt builds a Node.js server entry point at
- The server expects certain environment variables (like
- Disabling SSR (
- The knowledge sources do not provide specific information about running drizzle-kit migrations on shared hosting or within Nuxt deployments. 4. Running
- Some shared hosts require a loader (like a
Nuxt expects a Node.js environment where you can run the server entry point. Shared hosts may have limitations, especially if you cannot run background processes or custom Node.js scripts easily.
Nuxt Node.js Server Deployment - Static Hosting:
If SSR is disabled, you can deploy the generated static files to any static host, which is why your site works in this mode.
Nuxt Static Hosting - Database and Migrations:
There is no explicit information about drizzle-kit or how to run migrations on shared hosts in the provided sources. For serverless or static deployments, you must use an external database service, and migrations typically need to be run from a local environment or a CI/CD pipeline, not directly on the shared host (Serverless Hosting). Recommendations Based on the Sources - For SSR:
Ensure your host allows you to run a persistent Node.js process and that you can execute
Since the knowledge sources do not cover this, you may need to run migrations locally or via a CI/CD pipeline, then connect your Nuxt app to the already-migrated PostgreSQL database. - If SSR is not possible:
Consider deploying as a static site (with
- For SSR, Nuxt builds a Node.js server entry point at
.output/server/index.mjs
. This should be run with Node.js on the server (node .output/server/index.mjs
).- The server expects certain environment variables (like
PORT
, HOST
) and is typically run behind a reverse proxy (Nuxt Deployment Docs).
- PM2 is often used to manage the Node process, but this may not be available on shared hosts like o2switch.
2. Static vs SSR- Disabling SSR (
ssr: false
) allows you to deploy as a static site, which is easier on shared hosting but loses SSR benefits (Nuxt Deployment Docs).
3. Database Migrations (drizzle-kit)- The knowledge sources do not provide specific information about running drizzle-kit migrations on shared hosting or within Nuxt deployments. 4. Running
.mjs
on Shared Hosts- Some shared hosts require a loader (like a
loader.cjs
) to run .mjs
files, but this is not covered in the official Nuxt documentation.
What the Knowledge Sources Say
- SSR on Node.js Hosts:Nuxt expects a Node.js environment where you can run the server entry point. Shared hosts may have limitations, especially if you cannot run background processes or custom Node.js scripts easily.
Nuxt Node.js Server Deployment - Static Hosting:
If SSR is disabled, you can deploy the generated static files to any static host, which is why your site works in this mode.
Nuxt Static Hosting - Database and Migrations:
There is no explicit information about drizzle-kit or how to run migrations on shared hosts in the provided sources. For serverless or static deployments, you must use an external database service, and migrations typically need to be run from a local environment or a CI/CD pipeline, not directly on the shared host (Serverless Hosting). Recommendations Based on the Sources - For SSR:
Ensure your host allows you to run a persistent Node.js process and that you can execute
.output/server/index.mjs
with the correct environment variables. If the host requires a loader, follow their documentation, but this is outside the official Nuxt docs.
- For drizzle-kit migrations:Since the knowledge sources do not cover this, you may need to run migrations locally or via a CI/CD pipeline, then connect your Nuxt app to the already-migrated PostgreSQL database. - If SSR is not possible:
Consider deploying as a static site (with
ssr: false
), but be aware of the limitations (no server-side rendering, reduced SEO, etc.).
Limitations
I'm sorry, but the knowledge sources do not contain detailed information about deploying Nuxt SSR apps specifically on o2switch or about running drizzle-kit migrations in this context. For host-specific issues (like using a loader or running migrations), you may need to consult o2switch support or the drizzle-kit documentation.
If you have more specific questions about Nuxt's deployment process or configuration, feel free to ask!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@231454472948285440> Kapa.ai is still learning and improving, please let me know how I did by reacting below.