Update API base URL to use REACT_APP_BACKEND_URL and include '/api' path
This commit is contained in:
@@ -22,7 +22,8 @@
|
||||
"@types/cors": "^2.8.10",
|
||||
"@types/express": "^4.17.8",
|
||||
"@types/multer": "^1.4.5",
|
||||
"ts-node-dev": "^1.0.0",
|
||||
"typescript": "^4.0.3"
|
||||
"ts-node": "^10.9.2",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import path from 'path';
|
||||
|
||||
export default {
|
||||
storage: multer.diskStorage({
|
||||
destination: path.join(__dirname, '..','..','uploads'),
|
||||
destination: path.join(process.cwd(), 'uploads'),
|
||||
filename: (request, file, cb) => {
|
||||
const fileName = `${Date.now()}_${file.originalname}`;
|
||||
|
||||
|
||||
@@ -16,6 +16,4 @@ routes.post('/orphanages', upload.array('images'), OrphanagesController.create);
|
||||
routes.get('/orphanages', OrphanagesController.getAll);
|
||||
routes.get('/orphanages/:id', OrphanagesController.getIndex);
|
||||
|
||||
|
||||
|
||||
export default routes;
|
||||
@@ -4,7 +4,7 @@ import path from 'path';
|
||||
import 'express-async-errors';
|
||||
import cors from 'cors';
|
||||
|
||||
import './database/connection'; // This line now automatically runs the connection
|
||||
import './database/connection';
|
||||
import errorHandler from './errors/handler';
|
||||
import routes from './routes';
|
||||
|
||||
@@ -12,11 +12,15 @@ const app = express();
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use('/uploads', express.static(path.join(__dirname, '..', 'uploads')));
|
||||
|
||||
app.use('/api', routes);
|
||||
const uploadsPath = path.join(process.cwd(), 'uploads');
|
||||
app.use('/uploads', express.static(uploadsPath));
|
||||
app.use(routes);
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(process.env.PORT || 3101, () => {
|
||||
console.log(`Serving static files for /uploads from: ${uploadsPath}`);
|
||||
console.log('Server is running on http://localhost:' + (process.env.PORT || 3101));
|
||||
console.log('Environment:', process.env.NODE_ENV || 'development');
|
||||
});
|
||||
@@ -5,7 +5,7 @@ export default {
|
||||
render(image: Image) {
|
||||
return {
|
||||
id: image.id,
|
||||
url: `${process.env.BACKEND_URL}/uploads/${image.path}`
|
||||
url: `${process.env.REACT_APP_BACKEND_URL}/uploads/${image.path}`
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
"outDir": "./dist",
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user