'Serve a Nuxt app entirely prefixed (public files from baseURL)
I have a Nuxt app that I need to embed into another application. E.g. my app should serve the following URLs:
/prefix/
/prefix/all
/prefix/_nuxt/...
/prefix/scripts/abcd.js
And every other route is served by another application. I can handle the first 3 cases with
app: {
baseURL: '/prefix/',
}
However, I also need to serve some public (static) files from the same /prefix/. I tried putting my scripts into public/prefix, but Nuxt was serving the app on those URLs instead of my files.
I know about publicPath from Nuxt.js - is it possible to set custom path/base to staticfiles' urls?, however, I have control only over my /prefix/.
Is there a way to serve public files from the baseURL somehow?
Solution 1:[1]
Set your URL prefix in router.base in nuxt.config.js:
export default {
router: {
base: '/prefix'
}
}
Then put your static files into the static directory, and the entire app will be accessible at /prefix.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RWD |
