I am able to get the /api "Hello World" working both locally in dev and in prod on my server. The problem is that I'm unable to get the /api/files/posters endpoint when in prod. Any ideas?
Git repo linked below once I get it up
// In controller
@Get('posters')
async GetPosters(@Res() res: e.Response){
await this.fileService.GetFilesByDir(res, 'posters/');
}
// In service
async GetFilesByDir(res: e.Response, name: string) {
const data:string[] = [];
const path = name.endsWith('/')? name : name + '/';
const files = this.minioClient.listObjectsV2('monovrc', path, false);
files.on('error', function () {res.send({message: 'Error'})});
files.on('data', function (obj) { data.push(`http://content.monovrc.com/monovrc/${obj['name']}`)});
files.on('end', function (obj) {
console.log(data);
res.status(200).json({urls: data});
});
}
// main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api')
app.use(cookieParser());
//app.enableCors({credentials: true, origin: ['http://localhost:5173', 'https://monovrc.com', "http://monovrc.com", 'https://api.monovrc.com', "http://api.monovrc.com"]})
const config = new DocumentBuilder()
.setTitle('MonoVRC')
.setDescription('API backend for the MonoVRC website')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document);
await app.listen(3000);
}
bootstrap();
route shows in swagger UI
EDIT: https://github.com/YesVRC/Monochrome/blob/main/apps/api/src/files/files.service.ts
https://github.com/YesVRC/Monochrome/blob/main/apps/api/src/files/files.controller.ts