Skip to content

proxy ignore !**/mypath not working with build-angular:application builder #26942

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

Closed
1 task done
GreedyA1 opened this issue Jan 24, 2024 · 4 comments
Closed
1 task done

Comments

@GreedyA1
Copy link

GreedyA1 commented Jan 24, 2024

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

angular 16: build-angular:browser builder

Description

build-angular:browser proxy config supported ways to ignore some paths with syntax !**/
just the changing of builder breaks this behavior.

diff in branches
image

Minimal Reproduction

https://github.com/GreedyA1/test16/tree/main - with application builder

  • run node server/server.js
  • run ng serve --proxy-config=proxy.conf.js
image image

Exception or Error

No response

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 17.1.0
Node: 20.11.0
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 17.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.0
@angular-devkit/build-angular   17.1.0
@angular-devkit/core            17.1.0
@angular-devkit/schematics      17.1.0
@schematics/angular             17.1.0
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

The above proxy syntax is webpack-dev-server specific and is not handled by the underlying proxy package that is used by Vite.

You could use bypass which makes the proxy compatible with webpack-dev-server and vite.

const PROXY_CONFIG = [
  {
      context: [
        '/api/**',
      ],
      target: 'http://localhost:3000',
      secure: false,
      changeOrigin: true,
      logLevel: 'debug',
      bypass: function(req, res) {
        if (req.originalUrl.includes('/api/shmaybe')) {
          return req.originalUrl;
        }
    },
  },
]

module.exports = PROXY_CONFIG

@GreedyA1
Copy link
Author

looks like I'm getting different results depending on builders.

image vs webpack image

@alan-agius4
Copy link
Collaborator

That is due to #26917

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
@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 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants