Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable https #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@ middlewares = require('./speed-middleware')
sass = require('node-sass')
tildeImporter = require('node-sass-tilde-importer')


module.exports = (grunt) ->
pkg = grunt.file.readJSON('package.json')

accountName = process.env.VTEX_ACCOUNT or pkg.accountName or 'basedevmkp'
environment = process.env.VTEX_ENV or pkg.env or 'vtexcommercestable'
secureUrl = process.env.VTEX_SECURE_URL or pkg.secureUrl or true
port = process.env.PORT or pkg.port or 80
secureUrl = process.env.VTEX_SECURE_URL or pkg.secureUrl or false
if secureUrl
portAuto = 443
urlfim = "com.br"
environment = process.env.VTEX_ENV or pkg.env or 'vtexcommercestable'
else
portAuto = 80
urlfim = "com.br"
environment = process.env.VTEX_ENV or pkg.env or 'vtexcommercestable'

if secureUrl
secureProtocol = 'https'
else
secureProtocol = 'http'

port = process.env.PORT or pkg.port or portAuto or 80
console.log('Running on port ' + port)
console.log('Running on secureUrl ' + secureUrl)

compress = grunt.option('compress')
verbose = grunt.option('verbose')
Expand All @@ -29,7 +41,7 @@ module.exports = (grunt) ->

# portalHost is also used by connect-http-please
# example: basedevmkp.vtexcommercestable.com.br
portalHost = "#{accountName}.#{environment}.com.br"
portalHost = "#{accountName}.#{environment}.#{urlfim}"
localHost = "#{accountName}.vtexlocal.com.br"

if port isnt 80
Expand Down Expand Up @@ -185,6 +197,7 @@ module.exports = (grunt) ->
hostname: "*"
livereload: true
port: port
protocol: secureProtocol
middleware: [
middlewares.disableCompression
middlewares.rewriteLocationHeader(rewriteLocation)
Expand Down Expand Up @@ -250,4 +263,4 @@ module.exports = (grunt) ->
# Project configuration.
grunt.config.init config
grunt.loadNpmTasks name for name of pkg.devDependencies when name[0..5] is 'grunt-'
grunt.registerTask taskName, taskArray for taskName, taskArray of tasks
grunt.registerTask taskName, taskArray for taskName, taskArray of tasks
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ Clone this repo or download and unzip it.
"accountName": "your-store-account-name",
}
```
**Enable/Disable https**, please edit the `secureUrl` key to the `package.json` file. For example:
- **true** - Enable https and use port 443
- **false** - Disable https and use port 80
```json
{
"secureUrl": true,
}
```
**Important**
- https required disable/ignore warning in brownser.
- Enabling HTTPS automatically disables the livereload - [Read more about this issue](http://livereload.com/limitations/https/).

Enter the folder you cloned or downloaded, install dependencies and run `npm start`:

Expand Down
Loading