Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. How to enable CORS in Qt Webkit (QWebView)?
Forum Updated to NodeBB v4.3 + New Features

How to enable CORS in Qt Webkit (QWebView)?

Scheduled Pinned Locked Moved Qt WebKit
4 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vladimir.ks
    wrote on last edited by
    #1

    I get an error in debugger when trying to show some page. This is error "XMLHttpRequest cannot load http://... . Origin http://localhost is not allowed by Access-Control-Allow-Origin". I tried to add this flag page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true) but it seems it's doesn't work. Can you give me any suggestion?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to setup your server correctly to support CORS

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vladimir.ks
        wrote on last edited by
        #3

        [quote author="SGaist" date="1425340802"]Hi,

        You need to setup your server correctly to support CORS[/quote]

        Thank you for reply! But unfortunately it's not work. I tried to make some changes in config of lighttpd "setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )" but nothing changes.
        As additional info: this interface work in chrome with enabled addon named "Allow-Control-Allow-Origin". I have interface on my apache, code of interface made request to another domain and it works with enabled cors (and i have same error as in first message when it turned off)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Did you take a look at "that":http://doc.qt.io/qt-5/qwebsecurityorigin.html#addAccessWhitelistEntry ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved