Cors domain problem with – Kimo41 May 22 '19 at 23:21

  • Zak, I need share my contents openly!, without restrictions, is this a problem of browsers and not about the authorization of my .htaccess, maybe? – Kimo41 May 22 '19 at 23:25
  • Zak, Why create the – Kimo41 May 22 '19 at 23:32
  • Zak reply of your question..., What's to stop you from posting an iFrame of a bank login and collecting the user info?, the answer is simply, blocking using of iframe using .htaccess to all domains except the domain of bank, but the situation here is: 1. My site is not a bank!, 2. Im the owner of my site. – Kimo41 May 22 '19 at 23:44
  • Zak, And what about the sites who want allow cors access feature on his site?, they cannot use cors of his domains when they are the owners?, i really can't understand and i think your comment is out of topic. – Kimo41 May 22 '19 at 23:48
  • 1 Answers1

    -2

    Kimo41, i already read your comments, and i'm accord with you, the cors policy have to be decision of the owner of the website and domain, not of the web browsers, I think i have a good solution for you, you can try JS WORKERS, for allow cors in your domains if you are using Cloudflare as DNS.

    Response headers:

    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest(request) {
      let response = await fetch(request)
    
      // Make the headers mutable by re-constructing the Response.
      response = new Response(response.body, response)
      response.headers.set('x-my-header', 'custom value')
    
      return response
    }
    

    Request Headers:

    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest(request) {
      // Make the headers mutable by re-constructing the Request.
      request = new Request(request)
      request.headers.set('x-my-header', 'custom value')
    
      return await fetch(request)
    }
    
    Marcus R.
    • 14
    • 1
    • Thank you, i'm in a enterprise plan of cloudflare, it works, finally someone give me a good solution... – Kimo41 May 23 '19 at 01:18