thisandagain / fastly

Fastly API client for Node.js
MIT License
70 stars 28 forks source link

PURGE is broken in 2.2.0 #35

Open poscar opened 7 years ago

poscar commented 7 years ago

Looks like this change broke purging.

From the documentation:

The main entry point https://api.fastly.com/ for the API is not needed for an individual URL Instant Purge.

Also, looks like we shouldn't specify a body on the PURGE request, which we seem to be doing here: https://github.com/thisandagain/fastly/blob/develop/lib/index.js#L62-L65

These other docs indicate that for requests with API keys to work, it should be a POST request.

Our team reverted to 2.0.1 in order to get PURGE working again.

thisandagain commented 7 years ago

@markdorison any thoughts on this?

markdorison commented 7 years ago

🤔

These other docs indicate that for requests with API keys to work, it should be a POST request.

@poscar Are you referring to the warning at the bottom of the page related to non-HTTPS sites? That's the only mention I see about the request being a POST.

In contrast, this is the API doc I was working off for purge and soft purge which specifies a PURGE request type.

I am trying to reconcile the two documents in my head but I am unclear as to what we might be doing wrong when reviewing the API documentation. I am not able to reproduce an error but I am sure our test cases are different.

poscar commented 7 years ago

Thanks for the quick reply!

@markdorison The code here sends a PURGE request to url: 'https://api.fastly.com' + url, which is not what's specified in the documentation example curl -X PURGE http://www.example.com/image.jpg.

markdorison commented 7 years ago

@poscar Got it. Currently there is just that one function that handles all requests. One alternative would be to have to have a different path for this type of request. Maybe a different function? Or a conditional within that function?

@thisandagain what do you think?

bcoe commented 7 years ago

we're running into this problem too; purging from the Fastly console works like a charm, but the purge command via the authenticated client seems to do nothing.

hankmander commented 7 years ago

Any news on this? I have to use another lib to do the purging because of this bug.