Giter Site home page Giter Site logo

segfaultx64 / express-http-to-https Goto Github PK

View Code? Open in Web Editor NEW
36.0 36.0 13.0 12 KB

express-http-to-https is a node.js package for providing an Express middleware that redirects the client to HTTPS if they attempt to connect over HTTP.

License: MIT License

JavaScript 100.00%

express-http-to-https's People

Contributors

segfaultx64 avatar some-say avatar williamweckl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

express-http-to-https's Issues

ReferenceError: modules is not defined

I copy/pasted the exact example in the README.md file and ran it and it threw this error:

/path/to/my/app/node_modules/express-http-to-https/index.js:1
(function (exports, require, module, __filename, __dirname) { modules.exports = function redirectToHTTPS (ignoreHosts, ignoreRoutes) {
                                                              ^

ReferenceError: modules is not defined
    at Object.<anonymous> (/path/to/my/app/node_modules/express-http-to-https/index.js:1:63)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/path/to/my/app/server/test.js:4:23)
    at Module._compile (module.js:570:32)

What's the issue?

TypeError: search.test is not a function

I'm using an angular4/nodejs app.

In production, it seems to work fine, but with localhost I'm getting the type error in the title.

here is my stack trace

TypeError: search.test is not a function
    at ignores.some (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express-http-to-https/index.js:3:19)
    at Array.some (native)
    at searchIgnore (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express-http-to-https/index.js:2:18)
    at middlewareRedirectToHTTPS (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express-http-to-https/index.js:12:25)
    at Layer.handle [as handle_request] (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:317:13)
    at /Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:275:10)
    at expressInit (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:317:13)
    at /Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:275:10)
    at query (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/middleware/query.js:45:5)
    at Layer.handle [as handle_request] (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:317:13)
    at /Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/router/index.js:174:3)
    at Function.handle (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/application.js:174:10)
    at Server.app (/Users/jonathancorrin/Desktop/workspace/rent-app/node_modules/express/lib/express.js:38:9)
    at emitTwo (events.js:125:13)
    at Server.emit (events.js:213:7)
    at parserOnIncoming (_http_server.js:602:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)


Here is my node code

const redirectToHTTPS = require("express-http-to-https").redirectToHTTPS;

const app = express();

require('dotenv').config();

app.set('views', path.join(__dirname, './dist'));
app.set('view engine', 'ejs');

app.use(redirectToHTTPS([[/localhost:(\d{4})/]]));

Also, on a side note I ran it through chrome's lighthouse pwa tool and it states Im still not redirecting http tp https??

Exemple in NPM

Hello Guys!! Thank's for de module!!

I want just help other programs in future.

This line is incorrect in NPM example:

redirectToHTTPS = require('express-http-to-https')

Please if possible update this line in NPM example to:

redirectToHTTPS = require('express-http-to-https').redirectToHTTPS

Thank's for all!

Unnecessary check

Could you please explain why this check is needed ?

(parseInt(req.get('x-forwarded-port'), 10) === parseInt(req.get('x-forwarded-port'), 10))

redirectToHTTPS is not a function

I am working on node js and angular2 application.
const redirectToHTTPS = require('express-http-to-https'); app.use(redirectToHTTPS([/localhost:(\d{4})/], [/\/insecure/]));

It is giving error to me as redirectToHTTPS is not a function.

Allow 301 as optional

I would like to be able to decide if I want my redirects to use 301 as HTTP Status Code.

Thanks, very clean tool ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.