qtwebserver icon indicating copy to clipboard operation
qtwebserver copied to clipboard

CORS enable cross-origin resource sharing

Open phtag opened this issue 5 years ago • 4 comments

Have you have any experience with being blocked by CORS and having to enable it on the server side?

phtag avatar Dec 15 '19 18:12 phtag

Hey, unfortunately not. Is there any way your specific problem can be reproduced?

jacob3141 avatar Dec 15 '19 18:12 jacob3141

Thanks for the rapid response. My company rebuilt our application using Qt. I create a web server that communicates with our application using OLE/COM. I am contemplating replacing the OLE/COM functionality with a web server that is embedded in this application using QtWebServer or QtWebApp.

I believe there should be a way to set the header in the response function of the httpserver to enable CORS, e.g., response.headers().add(U("Access-Control-Allow-Origin"), U("*"));

I think all I need to do is to figure out the correct way to add an equivalent of the above to the header using your setHeader method.

I am not a C++ programmer.

Peter

On Sun, Dec 15, 2019 at 10:51 AM Jacob Dawid [email protected] wrote:

Hey, unfortunately not. Is there any way your specific problem can be reproduced?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jacob3141/qtwebserver/issues/16?email_source=notifications&email_token=AKUEJEL476M7APA7YRQA3E3QYZ4ENA5CNFSM4J3BMZ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG47S5A#issuecomment-565836148, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUEJEP5XO4FHPEKD3EKZWLQYZ4ENANCNFSM4J3BMZ6Q .

--

Horizon Systems BalancingPeter H. Tag, President

1072 S. De Anza Blvd.Suite A107, #397San Jose, CA 95129-3558505 897 [email protected] [email protected]

phtag avatar Dec 15 '19 22:12 phtag

I see. Just to be clear I'd like to note that this library is published under the AGPL, which means that it requires to make your main application open source even when it is used in a webservice. This is intentional and open to individual, paid licensing options in case you do not want to release your applications source code. The basic idea is that the project (and with it my work) is being either helped financially or through community work, which I think both are acceptable and have their use cases.

Yes, you are right, this should be possible via setHeader found in: https://github.com/jacob3141/qtwebserver/blob/9cb1d0898bf0f3a3ca8f460b036183d49730ecf3/http/httpresponse.h#L93

This method is overloaded, so you can use either predefined headers or declare any header you'd like to.

jacob3141 avatar Dec 15 '19 22:12 jacob3141

Thanks, David. I think we may experiment with QtWebServer. I believe we would go with the same licensing arrangements we have for our main application’s use of Qt

Peter

On Sun, Dec 15, 2019 at 3:59 PM Jacob Dawid [email protected] wrote:

I see. Just to be clear I'd like to note that this library is published under the AGPL, which means that it requires to make your main application open source even when it is used in a webservice. This is intentional and open to individual, paid licensing options in case you do not want to release your applications source code. The basic idea is that the project (and with it my work) is being either helped financially or through community work, which I think both are acceptable and have their use cases.

Yes, you are right, this should be possible via setHeader found in: https://github.com/jacob3141/qtwebserver/blob/master/http/httpresponse.h#L86

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jacob3141/qtwebserver/issues/16?email_source=notifications&email_token=AKUEJEMTCAPQGRKF7UXUOKDQY2ZGBA5CNFSM4J3BMZ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG5EPQI#issuecomment-565856193, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUEJELCILMA6D5WHCPVAXLQY2ZGBANCNFSM4J3BMZ6Q .

--

Horizon Systems BalancingPeter H. Tag, President

1072 S. De Anza Blvd.Suite A107, #397San Jose, CA 95129-3558505 897 [email protected] [email protected]

phtag avatar Dec 15 '19 23:12 phtag