vscode-live-server icon indicating copy to clipboard operation
vscode-live-server copied to clipboard

Status Code: 405 Method Not Allowed

Open MaxMan79 opened this issue 5 years ago • 28 comments

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request
[ ] Other: <!-- Please describe: -->

Current behavior

This is a duplicate of Issues #54 and #66, but they have been closed. I have tried the suggestions in Issue #54, but they did not work for me (i.e. running on a different port and killing any task running on port 5500).

I have a simple HTML form with method="post". When the form is submitted, Live Server returns a 405 Method Not Allowed. Looking in the browser Developer Tools, the Response header has "Allow: GET, HEAD, OPTIONS".

Expected behavior

I would expect Live Server to not serve back a 405 error :)

Environment

Windows 7 Home, 64-bit

Browser:

- [x] Chrome (desktop) version 76.0.3809.100 (64-bit)
- [x] Firefox version 68.0.1 (64-bit)
- [ ] Safari (desktop) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:

- Live Server: 5.6.1
- Platform:  Windows
- Visual Studio Code: 1.36.1

MaxMan79 avatar Aug 10 '19 13:08 MaxMan79

mark this issue

kanfashidoufu avatar Sep 04 '19 09:09 kanfashidoufu

we are having the same issue, we need help to solve this.

hyperfire13 avatar Oct 25 '19 07:10 hyperfire13

Same issue here too.

justinfarrelldev avatar Nov 03 '19 09:11 justinfarrelldev

Same here

dyeybermudez avatar Nov 04 '19 05:11 dyeybermudez

I managed to figure out what it was on my end. I was trying to get a package running (in particular, JQuery File Manager) and the package was trying to use Node.JS server calls to get the files on my server. Since it was only running through Live Server and not an actual Node server, it freaked out and this error was brought up. My fix was to actually transform my project into a real Node server.

justinfarrelldev avatar Nov 04 '19 07:11 justinfarrelldev

I managed to figure out what it was on my end. I was trying to get a package running (in particular, JQuery File Manager) and the package was trying to use Node.JS server calls to get the files on my server. Since it was only running through Live Server and not an actual Node server, it freaked out and this error was brought up. My fix was to actually transform my project into a real Node server.

yow correct me if I am wrong, so you stop using the vs code live server?

dyeybermudez avatar Nov 05 '19 02:11 dyeybermudez

I managed to figure out what it was on my end. I was trying to get a package running (in particular, JQuery File Manager) and the package was trying to use Node.JS server calls to get the files on my server. Since it was only running through Live Server and not an actual Node server, it freaked out and this error was brought up. My fix was to actually transform my project into a real Node server.

yow correct me if I am wrong, so you stop using the vs code live server?

Yea, I stopped using LiveServer in favor of using Node.

justinfarrelldev avatar Nov 08 '19 04:11 justinfarrelldev

Same issue.

Request URL: http://127.0.0.1:5500/
Request Method: POST
Status Code: 405 Method Not Allowed
Remote Address: 127.0.0.1:5500

raedmiranda avatar Nov 14 '19 19:11 raedmiranda

I think my issue is/was the same too. described here https://stackoverflow.com/questions/59024415/405-method-not-allowed-error-returned-upon-post-request-in-node-js-and-express/59027595#59027595

jrichalot avatar Nov 25 '19 21:11 jrichalot

I found the same issue: $.ajax('data/addToCart.json', { type: 'POST', dataType: 'json', contentType: 'application/json' })

Once I switch from Live Server to NodeJS's node-http-server the issue was no longer happening.

iszard avatar Dec 01 '19 04:12 iszard

Same issue. Just stopped using Live Server in VS Code.

ZahraB21 avatar Jan 11 '20 12:01 ZahraB21

I just had the same issue. https://stackoverflow.com/questions/60010357/405-method-not-allowed-in-simple-html-form-php-code

nahid18 avatar Jan 31 '20 20:01 nahid18

I just had the same issue. https://stackoverflow.com/questions/60010357/405-method-not-allowed-in-simple-html-form-php-code

Dropping live server extension seems to solve it for most.

jrichalot avatar Feb 05 '20 00:02 jrichalot

This is still an issue...

71GA avatar Nov 06 '20 20:11 71GA

This is still an issue:

Here is my code: const params = { id: 123, pepe: cuadrado, torre: 123456789 } fetch(url, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(params) }); and html:

Document

hola, running fetch

Visual Studio Code 1.54.3 from March 15 2021

spine001 avatar Mar 22 '21 17:03 spine001

This is still opened, maybe someone has an answer?

IlyaKaplan2002 avatar Oct 17 '21 18:10 IlyaKaplan2002

I just have the same issue

ghost avatar Oct 22 '21 12:10 ghost

Me as well.

anaconda121 avatar Dec 31 '21 02:12 anaconda121

Same issue. PHP Server by brapifra is working fine tho.

OS: Arch Linux Live Server: v5.7.4 VS Code: 1.63.2

dausruddin avatar Feb 01 '22 15:02 dausruddin

This issue is still on

helderpgoncalves avatar Oct 10 '22 18:10 helderpgoncalves

Same issue

yazzybandyham avatar Oct 28 '22 14:10 yazzybandyham

Same issue. Wow, this is old.

Earnest-Williams avatar Jan 18 '23 21:01 Earnest-Williams

I had the same problem, you can solve this problem by running a test server in the source folder of the website.

By simple running php -S localhost:8000, PHP will create a test server, and you'll be able to run yours tests

Pedro-Jaber avatar Jan 19 '23 17:01 Pedro-Jaber

same issue

kabirsumn avatar Aug 14 '23 06:08 kabirsumn

When posting form data, code Live server reports it only accepts: GET, HEAD, OPTIONS not POST

robertkendrick avatar Aug 20 '23 15:08 robertkendrick

When posting form data, Visual code Live server reports it only accepts: GET, HEAD, OPTIONS not POST Works fine in PHP server

POST scheme http host localhost:5500 filename /response.php/ Address 127.0.0.1:5500 Status 405 Method Not Allowed VersionHTTP/1.1 Transferred1.40 kB (0 B size) Referrer Policystrict-origin-when-cross-origin Request Priority Highest DNS Resolution System

Response Headers (271b) HTTP/1.1 405 Method Not Allowed Access-Control-Allow-Origin: http://localhost:5500 Vary: Origin Access-Control-Allow-Credentials: true Allow: GET, HEAD, OPTIONS Content-Length: 0 Date: Sun, 20 Aug 2023 16:00:08 GMT Connection: keep-alive Keep-Alive: timeout=5

Request Headers (1060b) POST /response.php/ HTTP/1.1 Host: localhost:5500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8 Accept-Language: en-GB,en;q=0.5 Accept-Encoding: gzip, deflate, br Content-Type: application/x-www-form-urlencoded Content-Length: 68 Origin: http://localhost:5500 Connection: keep-alive Referer: http://localhost:5500/myform.html Upgrade-Insecure-Requests: 1 Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-origin Sec-Fetch-User: ?1

robertkendrick avatar Aug 20 '23 16:08 robertkendrick

This issue still exists for me. However i overcome it by disabling live server and installed html-live server extension in VS code. Restart your vs code and then click on the html file and then click "start web preview server " . Make sure your backend server also listen to the same port and IP to which your frontend is hosted

sagarkarar avatar Mar 09 '24 15:03 sagarkarar

Issue still ongoing. Which is weird because the extension features list: "support for proxy" and "cors enabled". Only solution seems to be uninstalling Live Server

donner-dev avatar Sep 17 '24 17:09 donner-dev