Next.js Discord

Discord Forum

redirects to "/index.txt" bug

Unanswered
Bonga shad posted this in #help-forum
Open in Discord
Bonga shadOP
Hello, Anyone knows how to solve to this bug?

const submitTraitResultMutation = useMutation({
        mutationFn: async () => submitTraitResult(),
        onSuccess: () => {
            router.push('/trait/result')
        },
        onError: (error) => {
            ....
        },
    })

actual: it redirect to '/trait/result/index.txt'
expected: redirect to '/trait/result'

- not using canary
Version: 15.5.18

next.config.mjs
import analyzer from '@next/bundle-analyzer'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const withBundleAnalyzer = analyzer({
    enabled: process.env.ANALYZE === 'true',
})
const getDistDir = () => {
    if (process.env.NEXT_PUBLIC_ENV === 'LOCAL') {
        return undefined
    }
    return process.env.NEXT_PUBLIC_ENV === 'PRD' ? 'prd' : 'nonprd'
}
/** @type {import('next').NextConfig} */
const nextConfig = {
    output: 'export',
    distDir: getDistDir(),
    reactStrictMode: true,
    trailingSlash: true,
    images: {
        minimumCacheTTL: 0,
        unoptimized: true,
        domains: [
            'xxxx',
            'xxxx',
        ],
    },
    sassOptions: {
        includePaths: [path.join(__dirname, 'src', 'styles')],
    },
    webpack: (config) => {
        config.externals.push('pino-pretty', 'lokijs', 'encoding')
        config.watchOptions = {
            ...config?.watchOptions,
            ignored: ['node_modules', '.next', 'nonprd', 'prd'],
        }
        return config
    },
    compiler: {
        removeConsole: process.env.NODE_ENV === 'production',
    },
    turbopack: {
        resolveExtensions: ['.mdx', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],
        resolveAlias: {},
        rules: {
            '*.svg': {
                loaders: ['@svgr/webpack'],
                as: '*.js',
            },
        },
    },
}
export default withBundleAnalyzer(nextConfig)

0 Replies