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

Parcel report dev server overwriting headers set on proxyrc.js middlewares #6499

Closed
vitorcodesalittle opened this issue Jun 21, 2021 · 4 comments · Fixed by #6500
Closed

Comments

@vitorcodesalittle
Copy link
Contributor

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

.proxyrc.js

module.exports = function(app) {
  app.use((req, res, next) => {
    res.setHeader('Cross-Origin-Embedder-Policy', 'unsafe-none')
    next()
  })
}

.babelrc.json:

{
  "presets": [
    "@parcel/babel-preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "babel-plugin-transform-glob-import",
    "@parcel/babel-plugin-transform-runtime",
    ["import", { "libraryName": "antd", "libraryDirectory": "lib", "style": false}, "antd"],
    ["import", { "libraryName": "antd-new", "libraryDirectory": "lib", "style": "css"}, "antd-new"]
  ]
}

cli command:
parcel public/index.html --port 4000 --log-level verbose

🤔 Expected Behavior

Responses should have the header as defined on the middleware.

😯 Current Behavior

Response always with Cross-Origin-Embedder-Policy: require-corp. Probably also happens with other headers being set by

function setHeaders(res: Response) {

💁 Possible Solution

I believe is just a matter of the order of the middlewares being called. I would be glad try a PR once the issue is confirmed to be an issue.

🔦 Context

I wish I could have a more flexible development server.

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.720
Node 14.17.0
npm/Yarn 6.14.13
Operating System Fedora 34
@mischnic
Copy link
Member

I think it would make sense to call setHeaders before the proxyrc is applied 👍

@HenrikJoreteg
Copy link

This bit me.

I was just including Stripe and was surprised it didn't work when updating from Parcel 1 to Parcel 2. It's kind of uninituitive, IMO that something as benign as lazily loading 3rd party JS doesn't work.

@mischnic
Copy link
Member

This has been reverted: #6789

@HenrikJoreteg
Copy link

@mischnic thanks 😊

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

Successfully merging a pull request may close this issue.

3 participants