Skip to content

Commit

Permalink
Merge pull request #3530 from mikiher/subdirectory-fixes-2
Browse files Browse the repository at this point in the history
Add server proxies for all server paths
  • Loading branch information
advplyr authored Oct 17, 2024
2 parents f2102a0 + 49ed208 commit 2151ffa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 3 additions & 6 deletions client/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const pkg = require('./package.json')

const routerBasePath = process.env.ROUTER_BASE_PATH || ''
const serverHostUrl = process.env.NODE_ENV === 'production' ? '' : 'http://localhost:3333'
const serverPaths = ['api/', 'public/', 'hls/', 'auth/', 'feed/', 'status', 'login', 'logout', 'init']
const proxy = Object.fromEntries(serverPaths.map((path) => [`${routerBasePath}/${path}`, { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/' }]))

module.exports = {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
Expand Down Expand Up @@ -55,12 +57,7 @@ module.exports = {
// Modules: https://go.nuxtjs.dev/config-modules
modules: ['nuxt-socket-io', '@nuxtjs/axios', '@nuxtjs/proxy'],

proxy: {
[`${routerBasePath}/api/`]: { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/' },
[`${routerBasePath}/public/`]: { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/' },
[`${routerBasePath}/hls/`]: { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/' },
[`${routerBasePath}/dev/`]: { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/', pathRewrite: { '^/dev/': '' } }
},
proxy,

io: {
sockets: [
Expand Down
1 change: 0 additions & 1 deletion client/plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function ({ $axios, store, $config }) {

if (process.env.NODE_ENV === 'development') {
console.log('Making request to ' + config.url)
config.url = `/dev${config.url}`
}
})

Expand Down

0 comments on commit 2151ffa

Please sign in to comment.