mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Added multi-domain support. Maybe
This commit is contained in:
parent
368b40c9d1
commit
aae56e91c9
@ -12,11 +12,14 @@ module.exports = {
|
||||
// The registered domain where you will be serving the app. Use IP if none.
|
||||
domains: [
|
||||
|
||||
// Files will be served at https://i.kanacchi.moe/file.png
|
||||
{ base: 'https://i.kanacchi.moe/', prefix: ''},
|
||||
// Files will be served at http(s)://i.kanacchi.moe/Fxt0.png
|
||||
{ host: 'i.kanacchi.moe' },
|
||||
|
||||
// Files will be served at http://localhost:9999/files/file.png
|
||||
{ base: 'http://127.0.0.1:9999/', prefix: 'files/'}
|
||||
// Files will be served at http(s)://my.kanacchi.moe/loli-self/files/Fxt0.png
|
||||
{ host: 'my.kanacchi.moe', resolve: 'https://my.kanacchi.moe/loli-self/files' },
|
||||
|
||||
// Files will be served at http://localhost:9999/Fxt0.png
|
||||
{ domain: 'localhost:9999' }
|
||||
],
|
||||
|
||||
// Port on which to run the server
|
||||
|
@ -56,13 +56,19 @@ uploadsController.upload = function(req, res, next){
|
||||
|
||||
db.table('files').insert(files).then(() => {
|
||||
|
||||
let basedomain = req.get('host') + '/'
|
||||
for(let domain of config.domains)
|
||||
if(domain.host === req.get('host'))
|
||||
if(domain.hasOwnProperty('resolve'))
|
||||
return basedomain = domain.resolve + '/'
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
files: files.map(file => {
|
||||
return {
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
url: config.basedomain + file.name
|
||||
url: basedomain + file.name
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -12,11 +12,7 @@ fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder
|
||||
|
||||
safe.enable('trust proxy')
|
||||
|
||||
let prefix = config.uploads.prefix
|
||||
if( prefix !== '' )
|
||||
prefix = prefix + '/'
|
||||
|
||||
safe.use('/' + prefix, express.static('./uploads'))
|
||||
safe.use('/', express.static('./uploads'))
|
||||
safe.use('/', express.static('./public'))
|
||||
safe.use('/api', api)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user