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

next-image-loader does not respect assetPrefix #28305

Closed
ScriptedAlchemy opened this issue Aug 19, 2021 · 4 comments
Closed

next-image-loader does not respect assetPrefix #28305

ScriptedAlchemy opened this issue Aug 19, 2021 · 4 comments
Labels
bug Issue was opened via the bug report template.

Comments

@ScriptedAlchemy
Copy link
Contributor

ScriptedAlchemy commented Aug 19, 2021

What version of Next.js are you using?

11.1.0

What version of Node.js are you using?

14

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Other (serverless aws)

Describe the Bug

When specifying an asset prefix, images do not respect it.

 assetPrefix: isProd ? '/static/web-app/' : '',

images still emit paths like _next/ instead of /static/web-app/_next

Expected Behavior

Asset prefixes should be added to image paths.

I've been able to fix it with the following PR #28306

To Reproduce

Try adding an asset prefix via next config and check the image paths that are emitted.

@ScriptedAlchemy ScriptedAlchemy added the bug Issue was opened via the bug report template. label Aug 19, 2021
@timneutkens
Copy link
Member

timneutkens commented Aug 20, 2021

This is expected behavior as assetPrefix is being used by many users as a path to a static CDN and /_next/image needs server processing. This is similar to /_next/data which also needs to hit the Next.js server. If we'd release this change today then tomorrow there'd be bug report to implement the current behavior.

@PsyGik
Copy link

PsyGik commented Sep 16, 2021

So if one were to deploy multiple Next.js apps on a single domain, each app with it's own path...it isn't supported by Next.js?

App 1 - https://fancy.app/app-one
App 2 - https://fancy.app/app-two
App 3 - https://fancy.app/app-three

Based on how Next.js works today, _next/data/* for all the 3 apps would be https://fancy.app/_next/data/*, instead of respecting the path, https://fancy.app/app-one/_next/data/*.

So how is one supposed to deduce which request is for which app?

@styfle
Copy link
Member

styfle commented Sep 28, 2021

Fixed in #29307.

You can try it out on the canary channel with yarn add next@canary, thanks!

@styfle styfle closed this as completed Sep 28, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants