Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iron-ajax sets custom headers only as Access-Control-Request-Headers values #317

Open
2 tasks done
dabukster opened this issue Feb 27, 2018 · 1 comment
Open
2 tasks done

Comments

@dabukster
Copy link

dabukster commented Feb 27, 2018

Description

I'm using Polymer 2.0 and I want to set a custom header, like "x-personal-header": "some value"

<iron-ajax id="save" method="PUT" url="http://remotehost.net:9470/backend/resources/entities/Printer" body='{{currentItem}}'
      headers='{"access-control-allow-origin": "*"}' on-error="_handleError"
      handle-as="json" on-response="_handleResponse" debounce-duration="300"></iron-ajax>

Expected outcome

...other headers omitted...
x-personal-header: what

Actual outcome

...other headers omitted...
Access-Control-Request-Headers:x-personal-header

Steps to reproduce

  1. Put a iron-ajax element in the page and set headers headers='{"access-control-allow-origin": "*"}'
  2. Submit by clicking a button that invokes this.$.save.generateRequest()

Browsers Affected

  • Chrome
  • Firefox
@dabukster dabukster reopened this Feb 28, 2018
@dabukster dabukster changed the title iron-ajax does not set access-control-allow-origin header iron-ajax sets custom headers only as Access-Control-Request-Headers values Feb 28, 2018
@robdawsonthales
Copy link

@dabukster I was having this problem as well, turns out I needed to add an Access-Control-Allow-Headers header in the server response, like so:

Access-Control-Allow-Headers: *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants