Skip to content

Middleware for _next/image endpoint #40061

Answered by icyJoseph
GabrielOrtiz-at asked this question in Help
Discussion options

You must be logged in to vote

Hi,

Starting with next 12.2.x, you can use middleware only at the root, and it also sees _next internal calls!

With this page, configured domains in next.config.js:

import type { NextPage } from "next";
import Image from "next/image";

const Home: NextPage = () => {
  return (
    <div>
      <Image
        src="https://picsum.photos/200/300"
        alt="random"
        width={200}
        height={300}
      />
    </div>
  );
};

export default Home;

Then this middleware should do the trick for you:

im…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@icyJoseph
Comment options

@icyJoseph
Comment options

@giri-jeedigunta
Comment options

@icyJoseph
Comment options

@bestickley
Comment options

Answer selected by GabrielOrtiz-at
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants