Vue3路由器无法刷新生产

Vue3 router can not refresh on production

我有带路由器的 Vue3 应用程序。启用了历史记录模式,因此我希望能够将 vue.domain.com/path/to/view 写入浏览器地址栏并转到所需页面。但是正如我所见,路由器按预期创建了 url,但我无法刷新页面或通过地址栏直接转到另一个位置。您可以在此处查看带有登录页面 https://vue.tatrytec.eu/ Try refresh and you will see 404 not found error. The whole repository is on Github.

的示例

有人能告诉我这个问题的解决方案是什么吗?

编辑 我找到了解决方案,但不确定此 Apache 设置是否正确。这是来自 apache2/sites-available

的文件
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin xxx@xxxx.xx
        
        ServerName vue.tatrytec.eu

        ErrorLog ${APACHE_LOG_DIR}/www/vue.tatrytec.eu/error.log
        CustomLog ${APACHE_LOG_DIR}/www/vue.tatrytec.eu/access.log combined

        DocumentRoot /var/www/vue.tatrytec.eu/dist
        <Directory "/var/www/vue.tatrytec.eu/dist">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted               
        
                RewriteEngine on
                  RewriteBase /
                  RewriteRule ^index\.html$ - [L]
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule . /index.html [L]
        </Directory>


        SSLCertificateFile /etc/letsencrypt/live/vue.tatrytec.eu/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/vue.tatrytec.eu/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

您必须配置 Apache 网络服务器,以便它将所有请求路由到您的 index.html。参见 example