question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

always fallback legacy build when CSP

See original GitHub issue

Describe the bug

We use this line for detecting browser support. https://github.com/vitejs/vite/blob/08a1ec798184a7c8522b63d3795408568162c0e4/packages/plugin-legacy/index.js?_pjax=%23js-repo-pjax-container%2C div[itemtype%3D"http%3A%2F%2Fschema.org%2FSoftwareSourceCode"] main%2C [data-pjax-container]#L21

but new Function code doesn’t allow when CSP defaults. So the browser will always fallback. CSP hash can’t ignore unsafe-eval.

截圖 2021-12-01 下午7 10 43

Reproduction

HTTP server header

Content-Security-Policy: default-src 'self'

And Using @vite/plugin-legacy

Project: https://github.com/yoyo930021/vite-legacy-csp-bug

System Info

System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 2.49 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - ~/.volta/tools/image/node/14.18.1/bin/node
    Yarn: 2.4.2 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 7.22.0 - ~/.volta/tools/image/npm/7.22.0/bin/npm
  Browsers:
    Edge: 96.0.1054.34
    Firefox Developer Edition: 95.0
    Firefox Nightly: 96.0a1
    Safari: 15.0

Used Package Manager

yarn

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
patak-devcommented, Mar 29, 2022

We will release it in tandem with vite 2.9, hopefully this week

1reaction
yoyo930021commented, Jan 10, 2022

Did you find any walkaround for this?

No, I allow unsafe-eval for temp. But I have some idea to fix it. Maybe I will add a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Security Policy Level 3 - W3C
This document defines Content Security Policy (CSP), a tool which developers can use to lock down their applications in various ways, ...
Read more >
Content-Security-Policy - HTTP - MDN Web Docs
Serves as a fallback for the other fetch directives. ... Elements controlled by object-src are perhaps coincidentally considered legacy HTML ...
Read more >
In Depth: Content Security Policy - by Stephen Rees-Carter
A Content Security Policy (CSP) is an incredibly powerful web application security feature built into modern web browsers.
Read more >
How to Create a Content Security Policy (CSP Header)
It is now considered a legacy header and has been superseded by the Content Security Policy Header (CSP). The Content Security Policy header ......
Read more >
What does "legacy fallback" mean when cabal is building ...
When using cabal to build a Haskell package, it appears to mark some packages as legacy fallback : $ cabal build Resolving dependencies....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found