title: Download a pdf with server node and vue.js
body: <p>I have a problem . I must create a link for download a pdf with server but when click on link the file is not downloaded .</p>
  <p>it is important not to expose the PDF link in the client but download the file from the server.</p>
  <p>please help me!</p>
  <p>in front, I dit it</p>
  <pre><code>
      &lt;div class=&quot;historyNavBtns&quot;&gt;
        &lt;a
          v-if=&quot;isLoggedIn&quot;
          href=&quot;/tutorial&quot;
          @click=&quot;goLinkTutorial&quot;
        &gt;
          &lt;fa-icon
            class=&quot;btn bg-blue&quot;
            icon=&quot;info-circle&quot;
          /&gt;
        &lt;/a&gt;
  
  </code></pre>
  <p>my method to call api</p>
  <pre><code>  methods: {
      async goLinkTutorial () {
        try {
          await api.getLinkTutorial()
        } catch (error) {
          this.$store.dispatch('setMessage', { type: 'error', message: error, timeout: 2000 })
        }
      },
    },
  
  }
  </code></pre>
  <p>in api.js</p>
  <pre><code>export async function getLinkTutorial () {
    console.log('test')
    const response = await apiClient.get('/tutorial')
    return response.data
  }
  </code></pre>
  <p>In route</p>
  <pre><code>router.get('/', getTutorial)
  </code></pre>
  <p>in controller</p>
  <pre><code>import { techLogger } from '../util/logger.js'
  
  export const getTutorial = (req, res) =&gt; {
    try {
      res.type('application/pdf').download(new URL('../upload-folder/tutorial.pdf', import.meta.url).pathname, 'tutorial.pdf')
    } catch (error) {
      techLogger.info(error)
    }
  }
  </code></pre>