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.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

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

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest