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

fix(ssr): imported image paths set wrong #10982

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Conversation

LeoMcA
Copy link
Member

@LeoMcA LeoMcA commented Apr 23, 2024

Summary

Fixes https://mozilla-hub.atlassian.net/browse/MP-1088

Problem

On https://developer.mozilla.org/en-US/plus this error appears in the browser console:

Security Error: Content at https://developer.mozilla.org/en-US/plus may not load or link to file:///home/runner/work/yari/yari/ssr/dist//distimages/7023cc01db35a3cf8c89371f0e78da61.png.

This is because our ssr webpack config is improperly configured.

Solution

Copied the relevant lines from the client webpack config, in-lining the value for dataUrlCondition.maxSize (0) and adding the appropriate generator options to ensure the ssr doesn't output these assets and sets the appropriate asset url in the generated html.

The previous rule also set an svg rule, so moved that rule above into the svg config to maintain that behaviour (which in itself seems far from ideal, but seems to work - removing the rule breaks things).

This is still far from ideal but kept the change minimal to fix this specific issue, and I've tabled a discussion for the next engineering sync to discuss further fixes to the webpack config vs just switching to a different bundler.


Screenshots

No change


How did you test this change?

  • yarn dev
  • Loaded http://localhost:5042/en-US/plus/ with javascript disabled
  • Verified the first image (ai help) loaded, and the path matched the one added once javascript kicks in

due to a difference in how our client and ssr webpack configs were set up

https://mozilla-hub.atlassian.net/browse/MP-1088
@LeoMcA LeoMcA requested a review from a team as a code owner April 23, 2024 13:56
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

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

LGTM, haven't tested, just one nit.

Let's merge into next and see if it all works tomorrow.

ssr/webpack.config.js Show resolved Hide resolved
@caugner caugner merged commit 90c0e4f into main Apr 25, 2024
12 checks passed
@caugner caugner deleted the mp-1088-fix-ssr-image-paths branch April 25, 2024 09:14
LeoMcA added a commit that referenced this pull request Apr 26, 2024
follow up to #10982 which fixes things for svgs too
caugner pushed a commit that referenced this pull request May 2, 2024
follow up to #10982 which fixes things for svgs too
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.

2 participants