Skip to content

Instantly share code, notes, and snippets.

@tomasevich
Last active April 2, 2019 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasevich/e2e169b17c1cb1ac6351a0d0cddfc0af to your computer and use it in GitHub Desktop.
Save tomasevich/e2e169b17c1cb1ac6351a0d0cddfc0af to your computer and use it in GitHub Desktop.
Проксирование apache (httpd) для vue-cli (vue.js)

Проксирование apache (httpd) для vue-cli (vue.js)

В конфиге /etc/httpd/conf.d/mysite.ru.conf закомментируем строки (1) и впишем новые (2)

# Старые (1)
#<VirtualHost 0.0.0.0:80>
	#ServerName  mysite.ru
	#ServerAlias *.mysite.ru
	#CustomLog   /var/log/httpd/mysite.ru.access_log combined
	#ErrorLog    /var/log/httpd/mysite.ru.error_log
	#DocumentRoot    /var/www/domains/mysite.ru
#</VirtualHost>

# Новые (2)
<VirtualHost *:80>
	ProxyPreserveHost On
	ProxyPass / http://localhost:8080/
	ProxyPassReverse / http://localhost:8080/
</VirtualHost>

После рестартим апач, запускаем npm run serve (vue-cli) и радуемся

Внимание

Если выдает ошибку Invalid Host header, создаем конфиг для webpack (root_folder_of_app/vue.config.js) и указываем {disableHostCheck: true}

module.exports = {
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
          // изменение конфигурации для production...
        } else {
          // изменения для разработки...
        }
    },
    devServer: {
        disableHostCheck: true
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment