Skip to content

[Feature Request]: @storybook/nextjs to support redirects+rewrites from next.config.js #22020

@ryami333

Description

@ryami333

Is your feature request related to a problem? Please describe

I'm recently switched from the @storybook/react-webpack framework to the @storybook/nextjs framework with my NextJS project. Previously, I was using a .storybook/middleware.js file, which looked something like this:

const proxy = require("express-http-proxy");
const { join } = require("path");
const express = require("express");

const expressMiddleWare = (router) => {
  // `rewrite` for `/foo` to `imgix.bar.com/foo`
  router.use(
    "/foo",
    proxy("imgix.bar.com")
  );
};

module.exports = expressMiddleWare;

The routes were manually kept in-sync with the rewrites and redirects defined in next.config.js. I thought that after migrating to @storybook/nextjs that this would be handled natively by the framework and that I would be able to remove my middleware.js file, especially because the Middleware API is undocumented and unstable. Unfortunately that was not the case, and the framework does not do this.

Describe the solution you'd like

I would like it if @storybook/nextjs natively supported the rewrites and redirects defined in next.config.js, so that I do not have to manually configure them using the undocumented/unstable Middleware API.

Describe alternatives you've considered

As far as I can tell, the only way that Storybook can accommodate rewrites/redirects is via the Middleware API, but I'm open to alternative suggestions.

Are you able to assist to bring the feature to reality?

no

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions