Fix SSR 500 by proxying API requests to the Nuxt server port.
deploy to danak / build_and_deploy (push) Has been cancelled
deploy to danak / build_and_deploy (push) Has been cancelled
Point axios proxy at the same process as serverMiddleware instead of an unused port, and allow MongoDB URI to be configured via env. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+4
-2
@@ -1,5 +1,6 @@
|
|||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const serverport = 3711
|
const nuxtPort = process.env.PORT || 3000
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
head: {
|
head: {
|
||||||
title: 'OrisOxin',
|
title: 'OrisOxin',
|
||||||
@@ -74,7 +75,8 @@ export default {
|
|||||||
proxy: true
|
proxy: true
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': { target: `http://0.0.0.0:${serverport}` }
|
// SSR axios requests must hit the same Nuxt process that hosts serverMiddleware (/api).
|
||||||
|
'/api': { target: `http://127.0.0.1:${nuxtPort}` }
|
||||||
},
|
},
|
||||||
router: {
|
router: {
|
||||||
linkActiveClass: 'active-link',
|
linkActiveClass: 'active-link',
|
||||||
|
|||||||
@@ -1030,7 +1030,8 @@ export default {
|
|||||||
blogPosts: blogPosts.data
|
blogPosts: blogPosts.data
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error({ status: 500, message: 'there is a problem here' })
|
console.error('Homepage asyncData failed:', e.message || e)
|
||||||
|
error({ statusCode: 500, message: 'there is a problem here' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -13,9 +13,9 @@ mongoose.plugin(schema => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
mongoose.connect('mongodb://root:e9a15xftSaqNgR1fNMSUEHVqYDVh5XiDSW8Dt9sG1UyHvOE6nSTtQguaO4vor4Fp@noxkpqjq8ufxq969ut0v5p3m:27017/orisoxin?directConnection=true&authSource=admin', {
|
const mongoUri = process.env.MONGODB_URI || 'mongodb://root:e9a15xftSaqNgR1fNMSUEHVqYDVh5XiDSW8Dt9sG1UyHvOE6nSTtQguaO4vor4Fp@noxkpqjq8ufxq969ut0v5p3m:27017/orisoxin?directConnection=true&authSource=admin'
|
||||||
// mongoose.connect('mongodb://root:asrerb6udsf13sdfb6@srv-captain--danak-mongo-2:27017/orisoxin?authSource=admin', {
|
|
||||||
// mongoose.connect('mongodb://localhost:27017/OrisOxin', {
|
mongoose.connect(mongoUri, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useFindAndModify: false,
|
useFindAndModify: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user