Err_Unsafe_Redirect
I'm Trying to Get My Server to Redirect to Another Page in My 'Public Folder'. When I Use: Response. Redirect(Path. Join(__Dirname, '. ./Public/User_Home...
I'm trying to get my server to redirect to another page in my 'public folder'. When I use:
response.redirect(path.join(__dirname, '../public/user_home.html'))
I get and error net::ERR_UNSAFE_REDIRECT
On the client side I have:
$.get( "/user_home", function( data ) {console.log(data)};
I can't find anything about this error. Am I going about this incorrectly?
2 Answers
Your public folder is already available if you have static middleware configured in your app.
app.use(express.static('public'))
You can use:
res.redirect("/user_home.html");
response.redirect(path.join(__dirname, '../public/user_home.html'),safe=true)