FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
razzle/examples/with-devcert-https/razzle.config.js at master · javascriptit/razzle · GitHub
javascriptit
razzle
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
razzle
/
examples
/
with-devcert-https
/
razzle.config.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (57 loc) · 2.12 KB
Breadcrumbs
razzle
/
examples
/
with-devcert-https
/
razzle.config.js
Copy path
File metadata and controls
61 lines (57 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict'
;
const
devcert
=
require
(
'devcert'
)
;
const
cors
=
require
(
'cors'
)
;
const
whitelist
=
[
'https://localhost:3000'
,
'https://localhost:3001'
]
;
//white list consumers
const
corsOptions
=
{
origin
:
'*'
,
// function (origin, callback) {
// console.log(origin);
// if (whitelist.indexOf(origin) !== -1) {
// callback(null, true);
// } else {
// callback(null, false);
// }
// },
methods
:
[
'GET'
,
'PUT'
,
'POST'
,
'DELETE'
,
'OPTIONS'
]
,
optionsSuccessStatus
:
200
,
// some legacy browsers (IE11, various SmartTVs) choke on 204
credentials
:
true
,
//Credentials are cookies, authorization headers or TLS client certificates.
allowedHeaders
:
[
'Content-Type'
,
'Authorization'
,
'X-Requested-With'
,
'device-remember-token'
,
'Access-Control-Allow-Origin'
,
'Origin'
,
'Accept'
]
}
;
module
.
exports
=
{
modifyOptions
(
opts
)
{
// use modifyOptions so certificateFor is called once
const
options
=
opts
.
options
.
razzleOptions
;
return
new
Promise
(
async
(
resolve
)
=>
{
const
httpsCredentials
=
await
devcert
.
certificateFor
(
'localhost'
)
;
const
stringHttpsCredentials
=
{
key
:
httpsCredentials
.
key
.
toString
(
)
,
cert
:
httpsCredentials
.
cert
.
toString
(
)
}
;
options
.
HTTPS_CREDENTIALS
=
stringHttpsCredentials
;
resolve
(
options
)
;
}
)
;
}
,
modifyWebpackOptions
(
opts
)
{
const
razzleOptions
=
opts
.
options
.
razzleOptions
;
const
webpackOptions
=
opts
.
options
.
webpackOptions
;
if
(
opts
.
env
.
target
===
'node'
&&
opts
.
env
.
dev
)
{
webpackOptions
.
definePluginOptions
.
HTTPS_CREDENTIALS
=
JSON
.
stringify
(
razzleOptions
.
HTTPS_CREDENTIALS
)
;
}
return
webpackOptions
;
}
,
modifyWebpackConfig
(
opts
)
{
const
config
=
opts
.
webpackConfig
;
const
options
=
opts
.
options
.
razzleOptions
;
if
(
opts
.
env
.
target
===
'web'
&&
opts
.
env
.
dev
)
{
config
.
devServer
.
https
=
options
.
HTTPS_CREDENTIALS
;
// config.devServer.before = function (app, server, compiler) {
// app.use(cors('*')); console.log('web');
//
// }
config
.
devServer
.
headers
=
{
"Access-Control-Allow-Origin"
:
"*"
,
https
:
true
}
}
return
config
;
}
,
}
;
Back
|
FazBrowse Home
|
New Git URL