nuxt / nuxt/image

IPX Static Render Skipped with Custom BaseURL

Open
#1,394 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

When using the default IPX provider, if you've customized the provider's baseURL and it doesn't include /_ipx somewhere in the path, the images are not prerendered when performing a static build.

nuxt.config.ts

export default defineNuxtConfig({
  image: {
    ipxStatic: {
      baseURL: '/static-images'
    }
  }
})

It looks like the /src/runtime/utils/prerender.ts has hardcoded a filter looking for /_ipx/ which is what's causing this:
https://github.com/nuxt/image/blob/244f37ef22bfb23e04c994b30de5ba8e56e66fbf/src/runtime/utils/prerender.ts#L4-L12

I'm not intimately familiar with the codebase, but if there's a good way to either pass in the context that includes the current provider or some other good way of determining the provider, it seems like that could be used to determine if the ipxStatic.baseURL from the runtime config should be used.

Alternatively, since the prerender check is already hardcoded for /_ipx/, it might be sufficient to just check if there's a ipxStatic.baseURL in the runtime config and use that for the filter otherwise fallback to /_ipx/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/runtime/utils/prerender.ts and inspect the hardcoded /_ipx/ filter alongside the ipxStatic.baseURL example in the issue. Trace how runtime configuration is available during static builds. Done means a custom baseURL such as /static-images causes its images to be prerendered, while the default behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.