Repository navigation
Description
Command
serve
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Each OPTIONS request is automatically replaced with the 204 code type response, regardless the content and how the application intends to handle it.
OPTIONS type request is compliant with specification:
https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
and should be handled respectively.
This refers to https://github.com/webpack/webpack-dev-server/issues/4551 and partially to #23857
Minimal Reproduction
Any application using proxy functionality and sending OPTIONS requests.
Please find a basic project to reproduce this issue here: https://github.com/sek1973/options-issue.
Exception or Error
Depending on the application implementation it may cause unexpected http response for OPTIONS requests.
Your Environment
Angular CLI: 14.2.1
Node: 16.17.0
Package Manager: npm 8.18.0
OS: win32 x64
Angular: 14.2.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.1
@angular-devkit/build-angular 14.2.1
@angular-devkit/core 14.2.1
@angular-devkit/schematics 14.2.1
@angular/cli 14.2.1
@schematics/angular 14.2.1
rxjs 7.5.6
typescript 4.7.4
Anything else relevant?
@angular-devkit/[email protected] uses [email protected] internally.
Commenting out or removing following code in (node_modules\webpack-dev-server\lib\Server.js) seems to fix this issue:
{
/**
*
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @returns {void}
*
*/
const optionsRequestResponseMiddleware = (req, res, next) => {
if (req.method === "OPTIONS") {
res.statusCode = 204;
res.setHeader("Content-Length", "0");
res.end();
return;
}
next();
};
middlewares.push({
name: "options-middleware",
path: "*",
middleware: optionsRequestResponseMiddleware,
});
}
Activity
alan-agius4 commentedon Sep 5, 2022
Duplicate of #23857
angular-automatic-lock-bot commentedon Oct 6, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.