GenomeUS / keystone-express-sitemap

Dynamic sitemap generation for applications built on KeystoneJS
19 stars 15 forks source link

Added HTTPS #10

Open zahlio opened 5 years ago

zahlio commented 5 years ago

Added support for HTTPS.

BrandonM25 commented 5 years ago

I added the protocol:"https" and it still doesn't work. am I doing something wrong?

index.txt

jeserodz commented 5 years ago

@BrandonM25 I just tested it with the official Keystone demo project (https://github.com/keystonejs/keystone-demo) and it's working as expected.

If you're interested in using the forced HTTPS mode, you would need to install this package using git until this PR gets merged, using npm install --save git://github.com/ProjektA/keystone-express-sitemap.git

This is how the setup should look like:

// file: routes/index.js
const sitemap = require('keystone-express-sitemap');

exports = module.exports = function (app) {

  app.get('/sitemap.xml', function (req, res) {
    sitemap.create(keystone, req, res, {
      protocol: 'https'
    });
  });

  // Views
  app.get('/', routes.views.index);
  app.get('/blog/:category?', routes.views.blog);
  app.all('/blog/post/:post', routes.views.post);
  app.get('/gallery', routes.views.gallery);
  app.all('/contact', routes.views.contact);

  // Downloads
  app.get('/download/users', routes.download.users);
}

If this doesn't work, we might be able to help you if you share more details about how are you implementing it in your project.

BrandonM25 commented 5 years ago

I'm at a loss, my project isn't any different from the demo except for adding more pages and styling. here is my index.js its already been minified for web optimization sorry if its messy:

var keystone = require("keystone"), sitemap = require('keystone-express-sitemap'), middleware = require("./middleware"), importRoutes = keystone.importer(__dirname); keystone.pre("routes", middleware.initLocals), keystone.pre("render", middleware.flashMessages); var routes = { views: importRoutes("./views") }; exports = module.exports = function (app) { app.get('/sitemap.xml', function (req, res) { sitemap.create(keystone, req, res, { protocol: "https" }); }), app.get("/", routes.views.index), app.get("/blog/:category?", routes.views.blog), app.get("/blog/post/:post", routes.views.post), app.get("/gallery", routes.views.gallery), app.get("/menus/:menucategory?", routes.views.menus), app.get("/menus/menu/:menu", routes.views.menu), app.all("/contact", routes.views.contact), app.get("/cateringfaq", routes.views.cateringfaq) };`