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

In XP preview, next/image Images keep their local-to-next.js URLs even when src is prefixed with XP proxy #61

Closed
Tracked by #23
espen42 opened this issue Sep 15, 2021 · 6 comments

Comments

@espen42
Copy link
Contributor

espen42 commented Sep 15, 2021

When using the <Image tag from next/image, a src prop that refers to a file under src/public, is processed to a proprietary format.

For example:
import xpShield from '../../public/images/xp-shield.svg';
...and...
<Image src={xpShield}
...is server-side-rendered by next.js into...

/_next/image?url=%2F_next%2Fstatic%2Fimage%2Fsrc%2Fpublic%2Fimages%2Fxp-shield.074583348b1b4aee2574f3e054e22a93.svg&amp;w=96&amp;q=75

The XP-side proxy processes this to point to the asset proxy instead...

/_/service/com.example.myproject/assetProxy/_next/image?url=%2F_next%2Fstatic%2Fimage%2Fsrc%2Fpublic%2Fimages%2Fxp-shield.074583348b1b4aee2574f3e054e22a93.svg&amp;w=96&amp;q=75

But the browser still tries, and fails, to fetch the first-generated url from the XP root:
http://localhost:8080/_next/image?url=%2F_next%2Fstatic%2Fimage%2Fsrc%2Fpublic%2Fimages%2Fxp-shield.074583348b1b4aee2574f3e054e22a93.svg&w=96&q=75

@espen42
Copy link
Contributor Author

espen42 commented Sep 15, 2021

Path resolution, or hydration-update problem after the SSR? Might be related to #60 .

@sigdestad
Copy link
Member

Should probably not use the image "module" in next at all?

@sigdestad
Copy link
Member

Alas, images should be added with URL's from XP.

@espen42
Copy link
Contributor Author

espen42 commented Sep 15, 2021

As in, choose not to support it? We might, but it's such an encouraged part of next that a default linting rule in next is to break the build if <img is used instead of <Image.

@espen42
Copy link
Contributor Author

espen42 commented Sep 15, 2021

Two different things. Urls from XP are easier, this issue concerns next's /public/, the parallel to our /assets/. I think we should support this.

@espen42
Copy link
Contributor Author

espen42 commented Oct 6, 2021

The next.js <Image> tag is handy, but the url is difficult to handle for the proxy. Not prioritized for now.

@pmi pmi closed this as completed Mar 15, 2022
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

No branches or pull requests

3 participants