(req, res)
| 224 | require('./render-server') as typeof import('./render-server') |
| 225 | |
| 226 | const requestHandlerImpl: WorkerRequestHandler = async (req, res) => { |
| 227 | addRequestMeta(req, 'relativeProjectDir', relativeProjectDir) |
| 228 | |
| 229 | // internal headers should not be honored by the request handler |
| 230 | if (!process.env.NEXT_PRIVATE_TEST_HEADERS) { |
| 231 | filterInternalHeaders(req.headers) |
| 232 | } |
| 233 | |
| 234 | if ( |
| 235 | !opts.minimalMode && |
| 236 | config.i18n && |
| 237 | config.i18n.localeDetection !== false |
| 238 | ) { |
| 239 | const urlParts = (req.url || '').split('?', 1) |
| 240 | let urlNoQuery = urlParts[0] || '' |
| 241 | |
| 242 | if (config.basePath) { |
| 243 | urlNoQuery = removePathPrefix(urlNoQuery, config.basePath) |
| 244 | } |
| 245 | |
| 246 | const pathnameInfo = getNextPathnameInfo(urlNoQuery, { |
| 247 | nextConfig: config, |
| 248 | }) |
| 249 | |
| 250 | const domainLocale = detectDomainLocale( |
| 251 | config.i18n.domains, |
| 252 | getHostname({ hostname: urlNoQuery }, req.headers) |
| 253 | ) |
| 254 | |
| 255 | const defaultLocale = |
| 256 | domainLocale?.defaultLocale || config.i18n.defaultLocale |
| 257 | |
| 258 | const { getLocaleRedirect } = |
| 259 | require('../../shared/lib/i18n/get-locale-redirect') as typeof import('../../shared/lib/i18n/get-locale-redirect') |
| 260 | |
| 261 | const parsedUrl = parseUrlUtil((req.url || '')?.replace(/^\/+/, '/')) |
| 262 | |
| 263 | const redirect = getLocaleRedirect({ |
| 264 | defaultLocale, |
| 265 | domainLocale, |
| 266 | headers: req.headers, |
| 267 | nextConfig: config, |
| 268 | pathLocale: pathnameInfo.locale, |
| 269 | urlParsed: { |
| 270 | ...parsedUrl, |
| 271 | pathname: pathnameInfo.locale |
| 272 | ? `/${pathnameInfo.locale}${urlNoQuery}` |
| 273 | : urlNoQuery, |
| 274 | }, |
| 275 | }) |
| 276 | |
| 277 | if (redirect) { |
| 278 | res.setHeader('Location', redirect) |
| 279 | res.statusCode = RedirectStatusCode.TemporaryRedirect |
| 280 | res.end(redirect) |
| 281 | return |
| 282 | } |
| 283 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…