CORS issue with angularjs and POST, cont'd

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CORS issue with angularjs and POST, cont'd

Robert Ernens-3
And finally the content of the CORS.ini file

http://glctracker.golf-loisir-club.com/gps/
origin = *
methods = GET, POST, PUT, DELETE


And our version of the A4D_PostExecuteHook, implemented to workaround the
OPTIONS issue (401)

//METHOD: A4D_PostExecuteHook(
  //                 ioResponseHeaderNames: ->Text Array;
  //                 ioResponseHeaderValues: ->Text Array;
  //                 ioResponse: ->BLOB;
  //
  //Part of Active4D, the ultimate 4D web environment
  //Copyright © Aparajita Fishman, All Rights Reserved

C_POINTER($1;$ioResponseHeaderNames;$2;$ioResponseHeaderValues;$3;$ioRespon
se)
$ioResponseHeaderNames:=$1
$ioResponseHeaderValues:=$2
$ioResponse:=$3
C_TEXT($4;$url)
$url:=$4

  //----------------------------------------------------------------
  //Modify the headers or response here
  //----------------------------------------------------------------

If (Position("/GPS/";$url)>0)
 APPEND TO ARRAY($ioResponseHeaderNames->;"Access-Control-Allow-Origin")
 APPEND TO ARRAY($ioResponseHeaderValues->;"*")
 APPEND TO ARRAY($ioResponseHeaderNames->;"Access-Control-Allow-Headers")
 APPEND TO ARRAY($ioResponseHeaderValues->;"content-type")
 APPEND TO ARRAY($ioResponseHeaderNames->;"Access-Control-Allow-Methods")
 APPEND TO ARRAY($ioResponseHeaderValues->;"GET,POST,PUT,DELETE")
 APPEND TO ARRAY($ioResponseHeaderNames->;"Access-Control-Max-Age")
 APPEND TO ARRAY($ioResponseHeaderValues->;"10")
End if

  //----------------------------------------------------------------
  //If you modify ioResponse, change if (False) in the next line to if
(True)
  //----------------------------------------------------------------
If (False)
 C_LONGINT($index)
 $index:=Find in array($ioResponseHeaderNames->;"Content-Length")

 If ($index>0)
 $ioResponseHeaderValues->{$index}:=String(BLOB size($ioResponse->))
 End if
End if

Its invocation in A4D_onWebConnection has modified to pass the url as 4th
parm

A4D_PostExecuteHook
(->$responseHeaderNames;->$responseHeaderValues;->$response;$1)






--
Robert Ernens
HCTBA Consulting
Look2BookOnline - Web-à-la-Carte
4 Rés. Les Bois du Cerf
91450 Etiolles
Tél.: +33.950.58.95.80
GSM : +33.611.78.44.68


_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/
Reply | Threaded
Open this post in threaded view
|

CORS issue with angularjs and POST, cont'd

Robert Ernens-3



>Looks like I'll have to add parsing of JSON for the session id when the
>Content-Type is application/json. I should probably populate the _form
>collection with the parsed JSON as well.
>


I assumed that the json data was not parsed by active4D because of the
_data_ that let me believe that the payload was handled as raw data. So I
thought about parsing the content of the data myself to extract the
variables and using the query string to send the sid.

But there might be something else though !

When in such request, I send the sid as query string parm to overcome the
content of the payload not being parsed, Active4d does not recognize the
session anyway.

It looks like that if the Content-type is application/json query string
parms are not taken into account.

Am I right ?

Regards

--
Robert Ernens
HCTBA Consulting
Look2BookOnline - Web-à-la-Carte
4 Rés. Les Bois du Cerf
91450 Etiolles
Tél.: +33.950.58.95.80
GSM : +33.611.78.44.68


>


_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/