Send SDK version as X-SDK-Version header
Move the cookie-banner SDK version from the POST consents request body to a custom X-SDK-Version header sent on every API call. The server now reads it from the header and the CORS middleware allows it through preflight. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -122,7 +122,6 @@ type (
|
||||
Version int `json:"version"`
|
||||
Action coredata.CookieConsentAction `json:"action"`
|
||||
ConsentData json.RawMessage `json:"consent_data"`
|
||||
SdkVersion string `json:"sdk_version"`
|
||||
}
|
||||
|
||||
postConsentResponse struct {
|
||||
@@ -148,6 +147,7 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ip := clientip.Extract(r)
|
||||
ua := r.UserAgent()
|
||||
sdkVersion := r.Header.Get("X-SDK-Version")
|
||||
|
||||
req := cookiebanner.RecordConsentRequest{
|
||||
Version: body.Version,
|
||||
@@ -156,7 +156,7 @@ func (h *Handler) handlePostConsent(w http.ResponseWriter, r *http.Request) {
|
||||
UserAgent: &ua,
|
||||
ConsentData: body.ConsentData,
|
||||
Action: body.Action,
|
||||
SdkVersion: body.SdkVersion,
|
||||
SdkVersion: sdkVersion,
|
||||
}
|
||||
|
||||
record, err := h.cookieBannerSvc.RecordConsent(r.Context(), bannerID, req)
|
||||
|
||||
Reference in New Issue
Block a user