Question

How to set up Vue deployment properly in apps

Posted September 29, 2021 104 views
APIDeploymentVue.jsDigitalOcean App Platform

Hi guys, I recently set up and Django API using Digital Ocean Apps & I wanted to connect it to a Vue frontend.

When I was running Vue as a static site, it would only call localhost rather than targeting the API_URL which I set in my environment variables. I switched it to a web service, but now I’m getting

Invalid Host Header

whenever I navigate to the web page.

The Django app is deployed using gunicorn, but how should I be deploying the Vue component to allow myself to have a production version of vue running directly from my frontend component?

Currently I’m targeting the frontend with ${APPURL} and the backend with ${APPURL}/api.

I tried following the apps tutorial but I’m still a bit lost.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @jakesteele54,

The Invalid Host Header issue occurs when your application is set to listen on localhost instead of 0.0.0.0. That error typically indicates that the server isn’t accepting external connections. Please be sure that is set to run on 0.0.0.0.

You also may need to disable host checks as well:

// vue.config.js
module.exports = {
    // options...
    devServer: {
        disableHostCheck: true
    }
}

I hope this helps!

Cheers,
Taha Fatima