How to access next.config.mjs in server route
Answered
"use php" posted this in #help-forum
I'm trying to access next.config.mjs in server route
I'm doing this so I can get the
If I just use
I'll share my code
I'm doing this so I can get the
deviceSizes & imageSizes. Next.js Image optimisation doesn't work on the edge, hence I need to make some custom routes.If I just use
import, I get whole tons of errors Like:Module not found: Can't resolve 'diagnostics_channel'I'll share my code
Answered by "use php"
"just export them as constants from some mjs file and import them both into your page and the config file" -- Joulev
3 Replies
import config from
"@/../next.config.mjs"
const allowedWidths = [...config.images?.deviceSizes ?? defaultDeviceSizes, ...config.images?.imageSizes ?? defaultImageSizes]I get errors like
"just export them as constants from some mjs file and import them both into your page and the config file" -- Joulev
Answer