Skip to main content

Protected directory and API requests problem

Comments

2 comments

  • amirsolo
    After a day of searching and trying I finally solved that problem so there are 2 ways for solving this problem, that I know of :) 1. You can change the permission of all of those files and make them to 640 permission, and by 640 It means that you should uncheck the read permission under "world" so now, no one can read it even if they type the url and want to access your files 2. second way which is probably the better way to do it is to have a wild card in your Nodejs routes like this: [CODE=javascript]if (process.env.NODE_ENV === 'production') { app.use(express.static('./build')); app.get('*', (req, res) => { res.sendFile(path.resolve(__dirname, 'build', 'index.html')) }); }
    So you would have an index.html page to return to your users when they hit different urls and they won't get your private files It was really a simple problem but since there are not a lot of resources out there on deploying NodeJS apps on Cpanel, It could be a little frustrating to find a solutions. Hope this would help
    0
  • cPanelLauren
    Thank you very much for adding your resolution to this, I'm also glad to see you were able to fix the issue.
    0

Please sign in to leave a comment.