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

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) 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy