NetTalk Central

Author Topic: Access-Control-Allow-Origin  (Read 2388 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Access-Control-Allow-Origin
« on: February 06, 2017, 07:14:11 AM »
Hi,

I'm using a page script in Firefox to do a file upload to a NT web service method. The file is successfully uploaded, but the browser's console then returns an error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8080/UploadFile?FileExtension=PDF. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Because the file is successfully uploaded, the only reason I can think of for this error, is that the response might be missing information. I started reading about Access-Control-Allow-Origin, which is a response header used for cross-origin HTTP requests. Is there something in the NT web service that I can change to get this working?

Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Access-Control-Allow-Origin
« Reply #1 on: February 07, 2017, 12:32:55 AM »
Hi Thys,

There is a header you can set in the reply.

Probably the easiest way for you is in the WebServer procedure.
add
s_web._SitesQueue.Defaults.AccessControlAllowOrigin = '*'

just before the line
Put(s_web._SitesQueue)


Cheers
Bruce

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: Access-Control-Allow-Origin
« Reply #2 on: February 07, 2017, 02:22:40 AM »
Bruce.

The code should actually be:

s_web.HeaderDetails.AccessControlAllowOrigin = '*'

Firefox now accepts the response. I'm sure that Chrome and Edge should as well.

Thanks
Thys