Error 405 (CORS) on /api/history/period/ but not /api/states via REST API

HI all,

I am getting a strange error while developing a small web app (Javascript) that accesses my HA REST API.

Most of the API endpoints work well, e.g. I can get the states via /api/states, however, I am getting 405 Method Not Allowed errors when trying to access the history and logbook. I have tried different history URLs, e.g.

  • the default /api/history/period/
  • with setting minimal response /api/history/period/?minimal_response
  • or passing a start date /api/history/period/2021-04-05T00:00:00Z.

I get 405 on all of them. They work fine using python or via Postman (without CORS).

My web app is running on a local server. I tried accessing it via local IP, e.g. http://192.168.0.20:4200, as well as via localhost:4200. I access the HA API via my dyndns domain and SSL.

My HA config includes cors_allowed_origins:

api:

http:
  cors_allowed_origins:
    - "*"
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

Here are some screenshots from Firefox dev tools:



I’m lost as to what could be the problem. I hope someone can help :slight_smile:

Thanks a lot,

Moe

I’m having the exact same issue. Did you find what the problem is?

No, no luck so far.

Seems it’s a bug that is known: CORS preflight request not supported on the /api/history endpoint · Issue #39727 · home-assistant/core · GitHub

Since I am using influxdb anyway I’ll try to acces the data via that instead of the history API.