fix base64 csp error #279

Closed
HesterG wants to merge 2 commits from HesterG:fix-base64-csp into main
Member

patch for #276

The errors because some img src is converted to base64 by the framework (for some unknown reason, probably because of something like url-loader), which violets img-src 'self' related CSP rule

This PR explicitly use path as src for these images to fix this.

For long run, might need to find out why the framework turns the src into base64..

patch for #276 The errors because some img src is converted to base64 by the framework (for some unknown reason, probably because of something like `url-loader`), which violets `img-src 'self'` related CSP rule This PR explicitly use path as src for these images to fix this. For long run, might need to find out why the framework turns the src into base64..
HesterG added 2 commits 2023-07-18 01:49:19 +00:00
update
All checks were successful
check-and-test / check-and-test (pull_request) Successful in 2m20s
delete closed PR preview s3 / delete_preview (pull_request) Successful in 20s
381297e84d
pat-s approved these changes 2023-07-18 06:51:21 +00:00
Owner

The errors because some img src is converted to base64 by the framework (for some unknown reason, probably because of something like url-loader), which violets img-src 'self' related CSP rule

According to @yardenshoham, there's a configurable limit of bytes (10kb by default) below which docusaurus decides to inline the image instead of loading it externally.

> The errors because some img src is converted to base64 by the framework (for some unknown reason, probably because of something like url-loader), which violets img-src 'self' related CSP rule According to @yardenshoham, there's a configurable limit of bytes (10kb by default) below which docusaurus decides to inline the image instead of loading it externally.
Member

We just need to set an env var WEBPACK_URL_LOADER_LIMIT=1, maybe in the Makefile?

We just need to set an env var WEBPACK_URL_LOADER_LIMIT=1, maybe in the Makefile?
Author
Member

We just need to set an env var WEBPACK_URL_LOADER_LIMIT=1, maybe in the Makefile?

Thanks! I found the PR for this, and also the code and I tried the followings:

  • add WEBPACK_URL_LOADER_LIMIT=1 to Makefile, and do make server
  • add WEBPACK_URL_LOADER_LIMIT=1 to .env file
  • change to "start": "cross-env WEBPACK_URL_LOADER_LIMIT=1 docusaurus start --port 1313", in package.json

But none of them worked.. Maybe i am still using it wrong. Do you have any idea about what is a proper way to do it?

> We just need to set an env var WEBPACK_URL_LOADER_LIMIT=1, maybe in the Makefile? Thanks! I found the [PR](https://github.com/facebook/docusaurus/pull/5498) for this, and also [the code](https://github.com/facebook/docusaurus/blob/60e657d8ae5a4a9ed1c2d777f9defd882cc12681/packages/docusaurus-utils/src/constants.ts#L97) and I tried the followings: - add `WEBPACK_URL_LOADER_LIMIT=1` to `Makefile`, and do `make server` - add `WEBPACK_URL_LOADER_LIMIT=1` to `.env` file - change to `"start": "cross-env WEBPACK_URL_LOADER_LIMIT=1 docusaurus start --port 1313",` in `package.json` But none of them worked.. Maybe i am still using it wrong. Do you have any idea about what is a proper way to do it?
Author
Member

I removed node_modules and do npm i again, and then the environment variable works, so opened #280 to replace this PR.

I removed `node_modules` and do `npm i` again, and then the environment variable works, so opened https://gitea.com/gitea/blog/pulls/280 to replace this PR.
HesterG closed this pull request 2023-07-20 04:30:58 +00:00
HesterG deleted branch fix-base64-csp 2023-07-21 00:52:50 +00:00
All checks were successful
check-and-test / check-and-test (pull_request) Successful in 2m20s
Required
Details
delete closed PR preview s3 / delete_preview (pull_request) Successful in 20s

Pull request closed

Sign in to join this conversation.
No description provided.