Skip to content

Fix proxy bypass return false#1696

Merged
alexander-akait merged 8 commits into
webpack:masterfrom
mistic:fix-proxy-bypass-return-false
Mar 19, 2019
Merged

Fix proxy bypass return false#1696
alexander-akait merged 8 commits into
webpack:masterfrom
mistic:fix-proxy-bypass-return-false

Conversation

@mistic

@mistic mistic commented Feb 28, 2019

Copy link
Copy Markdown
Contributor
  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes

Motivation / Use-Case

Based on the explanation in the docs

It must return either false or a path that will be served instead of continuing to proxy the request.

It was expected that return false skip the proxy with a 404

Breaking Changes

None

Additional Info

Closes #1677

/CC @evilebottnawi

@jsmith-sapient @jshado1 @evilebottnawi could you please test this manually and confirm that this have the intended behaviour?

@codecov

codecov Bot commented Feb 28, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1696 into master will increase coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1696      +/-   ##
==========================================
+ Coverage   83.76%   83.85%   +0.09%     
==========================================
  Files           8        8              
  Lines         536      539       +3     
  Branches      161      162       +1     
==========================================
+ Hits          449      452       +3     
  Misses         70       70              
  Partials       17       17
Impacted Files Coverage Δ
lib/Server.js 79.05% <100%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34a4a26...5f3fa33. Read the comment docs.

Comment thread lib/Server.js Outdated

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just question

Comment thread lib/Server.js Outdated

@JakobJingleheimer JakobJingleheimer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested change (multiple nested ternaries and ifs) is too convoluted and has no code comments to help explain. No-one looking at this 5 minutes later would understand it 😨

Comment thread lib/Server.js Outdated
@mistic

mistic commented Mar 7, 2019

Copy link
Copy Markdown
Contributor Author

@evilebottnawi @jshado1 thanks for the suggestions. I tried to make the logic more clear and simple.

@JakobJingleheimer JakobJingleheimer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Comment thread lib/Server.js

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@mistic

mistic commented Mar 19, 2019

Copy link
Copy Markdown
Contributor Author

@evilebottnawi I think you can merge this 😄

@alexander-akait alexander-akait merged commit aa7de77 into webpack:master Mar 19, 2019
BH-M87 added a commit to BH-M87/generator-cool that referenced this pull request Apr 9, 2019
Comment thread lib/Server.js
? proxyConfig.bypass(req, res, proxyConfig)
: null;

if (typeof bypassUrl === 'boolean') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not aligning to the documentation

In the function you get access to the request, response and proxy options. It must return either false or a path that will be served instead of continuing to proxy the request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR welcome to webpack docs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proxy.bypass return false does not work

6 participants