How to deploy Nuxt SSR with mod_rewrite in a sub f

2019-08-17 06:04发布

Currently I'm running a Django based website. I want to replace my "/admin/" area with a Vue/Nuxt build version but keep the rest of my website for now.

To serve my files I use Apache2 with mod_rewrite enabled. My Nuxt server is running on localhost:3000.

In my .htaccess I wrote this line to proxy /admin/ to the Nuxt Server

RewriteRule ^admin/(.*) http://localhost:3000/$1 [P]

If I access www.example.com/admin/ I see the output of my Nuxt project. But all resources are not loaded because the paths are wrong.

Instead of www.example.com/admin/.nuxt/... Nuxt is "looking" to www.example.com/.nuxt/

How can I change this?

1条回答
男人必须洒脱
2楼-- · 2019-08-17 06:34

I finally solved the problem on my own:

Solution

nuxt.config.js

  router: {
    base: "/myapp/"
  },

.htaccess

RewriteRule ^myapp/(.*) http://localhost:3000/myapp/$1 [P]
RewriteRule ^_nuxt/(.*) http://localhost:3000/_nuxt/$1 [P]
查看更多
登录 后发表回答