Background Information
- I am working on a NodeJS w/ Express project.
- There are publicly visible buttons that should allow file downloads, and these buttons have protected routes which redirect the user to a login page if they are not logged in.
- I am storing some information related to file downloads in a cookie, and that is working. Essentially it is
need_to_download_file2 == true
The Problem
Once the user authenticates, I want to redirect them to the home page and then start a file download for the file they originally clicked on. As of now, everything is working, but the file download does not start after the redirect, the user must click download again to initiate it.
Main Approach:
- I am attempting to call
window.open('/download/file2')
in the index.html page'sonLoad()
event. However, the network tab shows the request as being cancelled. This is all that is contained in theonLoad()
event.
// onLoad
function hidePreloader () {
document.getElementById('preloader').style.display = 'none'
document.getElementById('contentDiv').style.display = 'block'
window.open('localhost:3000/download/file2','_self');
}
I would really appreciate any help, and can provide more information if needed!
Thanks in advance.