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

esbuild with proxy doesn't return Content-Language headers for OPTIONS request #26782

Closed
mivanyna opened this issue Jan 3, 2024 · 13 comments · Fixed by #26871
Closed

esbuild with proxy doesn't return Content-Language headers for OPTIONS request #26782

mivanyna opened this issue Jan 3, 2024 · 13 comments · Fixed by #26871

Comments

@mivanyna
Copy link

mivanyna commented Jan 3, 2024

Which @angular/* package(s) are the source of the bug?

upgrade, Don't known / other

Is this a regression?

Yes

Description

I upgraded my project to Angular 17 and switched to "builder": "@angular-devkit/build-angular:browser-esbuild". For local env I use proxy config to redirect requests to test env.

I receive all the data, except for OPTIONS request there is no Content-Language header in response.
It works on prev version(Angular 16 and "builder": "@angular-devkit/build-angular:browser")

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.7
Node: 21.5.0 (Unsupported)
Package Manager: yarn 1.22.19
OS: win32 x64

Angular: 17.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... upgrade

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.7
@angular-devkit/build-angular   17.0.7
@angular-devkit/architect       0.1700.7
@angular-devkit/build-angular   17.0.7
@angular-devkit/core            17.0.7
@angular-devkit/schematics      17.0.7
@schematics/angular             17.0.7
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

I switched to "builder": "@angular-devkit/build-angular:browser-esbuild"
With proxy for the local env
package.json:

{
...
"start": "ng serve --proxy-config config/proxy.conf.js --hmr --port 3000 --open=true",
...
}

My proxy config looks like this:

const PROXY_CONFIG = [
  {
    context: [
      "/api"
    ],
    target: "test env link",
    secure: true,
    changeOrigin: true,
  }
]

module.exports = PROXY_CONFIG;
@mivanyna mivanyna changed the title esbuild with proxy doesn't return Content-Language headers esbuild with proxy doesn't return Content-Language headers for OPTIONS request Jan 3, 2024
@JeanMeche JeanMeche transferred this issue from angular/angular Jan 3, 2024
@mivanyna
Copy link
Author

mivanyna commented Jan 4, 2024

Please let me know if you need something from me

@mivanyna
Copy link
Author

mivanyna commented Jan 5, 2024

This one is very critical for me as it blocks development of some parts of the app

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 5, 2024

Hi @mivanyna, to speed up our investigation kindly provide a minimal reproduction.

A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

That being said, it's unlikely this is a bug from our end as proxy is handled by Vite.

@alan-agius4
Copy link
Collaborator

@mivanyna, following an offline convo with @clydin, he correctly pointed out that an OPTIONS response has no content and thus, what is the reason of having a content-language header in the first place?

@mivanyna
Copy link
Author

mivanyna commented Jan 5, 2024

@alan-agius4 I get localizations in the header so I can then fetch the data with GET for the locale

@mivanyna
Copy link
Author

Hi there, were you able to reproduce the issue?

@alan-agius4
Copy link
Collaborator

@mivanyna, unfortunately, I was not able yet to look into this issue. As mentioned above, it would definitely speed up the process if you share a minimal reproduction.

@ipranjic
Copy link

Hi @mivanyna, look at this issue: #25337
I think you have the same problem - the array form of proxy configuration is not yet supported by Vite. Instead you should do it like this:

module.exports = {
  "api/": { 
      target: "test env link",
      secure: true,
      changeOrigin: true
    }
 }

@mivanyna
Copy link
Author

Hi @ipranjic , I don't think it's the case as I get all other data(GET, POST, etc)

@mivanyna
Copy link
Author

@alan-agius4 here is the repo.

What I noticed is that even if the backend server is not running I get the response for OPTIONS request, seems like the dev-server returns it.

@alan-agius4 alan-agius4 self-assigned this Jan 15, 2024
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity3: broken and removed needs: investigation Requires some digging to determine if action is needed labels Jan 15, 2024
@alan-agius4
Copy link
Collaborator

@mivanyna, I managed to find the root cause and will be opening a PR shortly.

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jan 15, 2024
…roxied when using `vite`

This commit fixes an issue were `OPTIONS` requests were not being proxied when using Vite dev-server

Closes angular#26782
alan-agius4 added a commit that referenced this issue Jan 16, 2024
…roxied when using `vite`

This commit fixes an issue were `OPTIONS` requests were not being proxied when using Vite dev-server

Closes #26782
alan-agius4 added a commit that referenced this issue Jan 16, 2024
…roxied when using `vite`

This commit fixes an issue were `OPTIONS` requests were not being proxied when using Vite dev-server

Closes #26782

(cherry picked from commit 771fdcd)
@mivanyna
Copy link
Author

Thanks @alan-agius4

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants