I am using a route with parameters on the front end to node express using axios:
await axios.delete(`/api/delete/file/${folder}`)
Then on node express I use the route with a parameter
server.js
import { deleteFile } from './node/controllers/delete-controller.js'
app.use('/api', router)
router.delete('/delete/file/:folder', deleteFile)
delete-controller.js
export const deleteFile = async (req, res) => {
await unlink(`./projects/${req.params.folder}/data.json`)
res.end()
}
On production, how should I set the nginx proxy pass? Currently I have this but it does not work.
location /api/delete/file {
proxy_pass http://localhost:5006/api/delete/file;
}
Or
location ~ ^/api/delete/file(/?)(.*) {
proxy_pass http://localhost:5006/api/delete/file$1;
}
I get: 404
If I do
location /api/delete/file/?(.*) {
proxy_pass http://localhost:5006/api/delete/file;
}
I get: 405 Method Not Allowed