Deployment of NuxtJS 3 on cPanel
anyone deployed nuxtjs with pm2 on capnel and can point in the right direction? I have set up proxy server as required and it works, but the nuxt give me this error:
on the nuxt app itself (the domain), this is what I see:
The include.conf files in the server on
ssl/2_4/cpaneluser/domain and std/2_4/cpaneluser/domain are correctly configured2 Replies
Hi @Shay Rosenfeld. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there is no direct documentation or example specifically about deploying Nuxt 3 with PM2 on cPanel. However, your error message:
suggests that the base URL being constructed by Nitro (the Nuxt server engine) is invalid, likely due to a misconfiguration in your environment or proxy setup.
Here are some relevant points and suggestions based on the sources:
1. Base URL Configuration
Ensure that your
When deploying behind a proxy (like Apache or Nginx, which cPanel often uses), make sure your proxy configuration forwards the correct headers, especially
Your PM2 config should point to
The error shows
- Double-check your proxy and environment variable setup. - Make sure you are not setting
The error is likely due to a misconfiguration in your proxy or environment variables, causing Nitro to receive an invalid base URL. Double-check your
Ensure that your
app.baseURL in nuxt.config.js is set correctly. If your app is served from the root, it should be /. If it's in a subdirectory, set it to that subdirectory (e.g., /app/). Incorrect base URLs can cause asset and routing issues, especially behind proxies or in subdirectory deployments. See the Nuxt app configuration docs.
2. Proxy and Reverse ProxyWhen deploying behind a proxy (like Apache or Nginx, which cPanel often uses), make sure your proxy configuration forwards the correct headers, especially
Host and X-Forwarded-Proto. This helps Nitro construct the correct absolute URLs. Example Nginx config for Nuxt:
See example
3. PM2 ConfigurationYour PM2 config should point to
.output/server/index.mjs and set the correct port. Example:
See deployment docs
4. Check for Double Domain in BaseThe error shows
base: '<https://[your-domain],> [your-domain]', which looks like a misconfigured environment variable or header. Make sure you are not setting the base URL or related environment variables with a comma or multiple domains.
5. General Troubleshooting- Double-check your proxy and environment variable setup. - Make sure you are not setting
NUXT_APP_BASE_URL or similar variables incorrectly.
- If using SSL, ensure your proxy handles SSL termination and forwards requests to Nuxt over HTTP, unless you have configured Nitro to handle SSL directly (not recommended for production) see deployment docs.
Summary:The error is likely due to a misconfiguration in your proxy or environment variables, causing Nitro to receive an invalid base URL. Double-check your
nuxt.config.js (app.baseURL), your proxy headers, and any environment variables related to the base URL or host. If you are deploying in a subdirectory, ensure all related settings and proxy rules match that subdirectory.
If you need more specific help, please provide your nuxt.config.js and the relevant proxy configuration. The knowledge sources do not contain a cPanel-specific guide, but the general Nuxt 3 deployment and proxying principles apply.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@578603590927646754> Kapa.ai is still learning and improving, please let me know how I did by reacting below.