Skip to content

Instantly share code, notes, and snippets.

@aweber1
aweber1 / parseRequestUrl.js
Created April 4, 2020 12:16
Node.js parse request url
import { IncomingMessage } from 'http';
import { TLSSocket } from 'tls';
import { URL } from 'url';
export function parseRequestUrl(req: IncomingMessage) {
let protocol = 'http';
if ((req.socket as TLSSocket).encrypted) {
protocol = 'https';
}
@aweber1
aweber1 / next-webpack-disable-optimization-plugin.js
Last active February 6, 2024 07:54
NextJS Webpack disable optimization plugin
module.exports = (nextConfig) => {
return Object.assign({}, nextConfig, {
webpack(webpackConfig, nextContext) {
// NOTE: use whatever environment variable you'd like here to determine
// what environment should have minimization disabled.
if (process.env.NODE_ENV === 'development') {
webpackConfig.optimization.minimize = false;
webpackConfig.optimization.minimizer = [];
}