Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
HTML-Image-Tag Source request Authorization header in Vue.js 3

So, basically I'm trying to intercept the request from the HTML-Image-Tag, so that I can add my authorization header. I'm trying to do this with Vue.js 3. I've already tried to use a ServiceWorker to do so, but this didn't work as expected. The URLs called from the HTML-Image-Tag source will redirect to a cloud image. I can intercept the request, but cannot redirect to the destination url. I'm also still getting authorization errors.

Here is my code:

// imageInterceptor.js (in root folder)
self.addEventListener('fetch', (event) => {
  console.log(event)

  const newRequest = new Request(event.request, {
    headers: {
      Authorization:
        'Bearer __My-Token__',
    },
  })
  return fetch(newRequest)
})

// Registration in main.ts
await navigator.serviceWorker.register('/imageInterceptor.js')
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!