⨯ Middleware cannot be used with "output: export".
Answered
Schweizer Laufhund posted this in #help-forum
Schweizer LaufhundOP
My current next.config
What do I change? I have auth middleware (lucia)
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export", // Outputs a Single-Page Application (SPA).
distDir: "./dist", // Changes the build output directory to `./dist/`.
webpack: (config) => {
config.externals.push("@node-rs/argon2", "@node-rs/bcrypt");
return config;
},
};
export default nextConfig;
What do I change? I have auth middleware (lucia)
17 Replies
Answer
I think you're using the wrong export for the job here
Basically, setting
output: export
turns your app into a completely static HTML/CSS application, like an oldschool style appI'm simplifying a bit, but that's the general gist
Naturally, when compiling your complex React application with auth, etc, to a completely static app that you can run on anything, you lose a ton of functionality
The export output type is usually for if you're making some kind of website with little to no interaction, essentially like you're making an old school HTML app, but you want to write it in react because of the developer experience.
If I had to guess, and given you're using Lucia auth, I think the output type you're looking for is
output: standalone
That's typically what I see on most production apps, and should support your middleware just fine 🙂
100% correct,
output: "export"
indicates that its a static export, you can have something thats static with middleware.sorry just sanity checking, did you mean can't? want to make sure I'm not off base
Yeah it’s “can’t”
roger, thank y'all 🙏
Sorry 😦
nothing to be sorry about at all, honestly was just sanity checking to make sure I didn't just answer with a wall of lies 😂
still relatively new to next myself
All good, I was happy to see someone else giving a good comprehensive answer then I came in and put doubt in everyones mind 😄
Schweizer LaufhundOP
thanks this worked