Skip to content

Commit cd477a6

Browse files
committed
updating firewall config for webpack-dev-server 4
1 parent f471149 commit cd477a6

File tree

1 file changed

+45
-50
lines changed

1 file changed

+45
-50
lines changed

frontend/encore/dev-server.rst

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,6 @@ As a consequence, the ``link`` and ``script`` tags need to point to the new serv
1818
:ref:`processing your assets through entrypoints.json <load-manifest-files>` in some other way),
1919
you're done: the paths in your templates will automatically point to the dev server.
2020

21-
Enabling HTTPS using the Symfony Web Server
22-
-------------------------------------------
23-
24-
If you're using the :doc:`Symfony web server </setup/symfony_server>` locally with HTTPS,
25-
you'll need to also tell the dev-server to use HTTPS. To do this, you can reuse the Symfony web
26-
server SSL certificate:
27-
28-
.. code-block:: terminal
29-
30-
# Unix-based systems
31-
$ yarn dev-server --https --pfx=$HOME/.symfony/certs/default.p12
32-
33-
# Windows
34-
$ encore dev-server --https --pfx=%UserProfile%\.symfony\certs\default.p12
35-
36-
To avoid repeating yourself, you can also update ``package.json`` to include
37-
these options automatically:
38-
39-
.. code-block:: diff
40-
41-
{
42-
...
43-
"scripts": {
44-
- "dev-server": "encore dev-server",
45-
+ "dev-server": "encore dev-server --https --pfx=$HOME/.symfony/certs/default.p12 --allowed-hosts=mydomain.wip",
46-
...
47-
}
48-
}
49-
50-
If you experience issues related to CORS (Cross Origin Resource Sharing), add
51-
the ``--firewall false`` and ``--port`` options to the ``dev-server``
52-
command in the ``package.json`` file:
53-
54-
.. code-block:: diff
55-
56-
{
57-
...
58-
"scripts": {
59-
- "dev-server": "encore dev-server",
60-
+ "dev-server": "encore dev-server --port 8080 --firewall false",
61-
...
62-
}
63-
}
64-
65-
.. caution::
66-
67-
Beware that `it's not recommended to disable host checking`_ in general, but
68-
here it's required to solve the CORS issue.
69-
7021
dev-server Options
7122
------------------
7223

@@ -100,6 +51,51 @@ method in your ``webpack.config.js`` file:
10051

10152
The ``Encore.configureDevServerOptions()`` method was introduced in Encore 0.28.4.
10253

54+
Enabling HTTPS using the Symfony Web Server
55+
-------------------------------------------
56+
57+
If you're using the :doc:`Symfony web server </setup/symfony_server>` locally with HTTPS,
58+
you'll need to also tell the dev-server to use HTTPS. To do this, you can reuse the Symfony web
59+
server SSL certificate:
60+
61+
.. code-block:: javascript
62+
63+
// webpack.config.js
64+
// ...
65+
66+
Encore
67+
// ...
68+
69+
.configureDevServerOptions(options => {
70+
options.https = {
71+
pfx: '/path/to/.symfony/certs/default.p12',
72+
}
73+
})
74+
75+
Then make sure you run the ``dev-server`` with the ``--https`` option:
76+
77+
.. code-block:: terminal
78+
79+
$ yarn encore dev-server --https
80+
81+
CORS Issues
82+
-----------
83+
84+
If you experience issues related to CORS (Cross Origin Resource Sharing), set
85+
the ``firewall`` option:
86+
87+
.. code-block:: javascript
88+
89+
// webpack.config.js
90+
// ...
91+
92+
Encore
93+
// ...
94+
95+
.configureDevServerOptions(options => {
96+
options.firewall = false;
97+
})
98+
10399
Hot Module Replacement HMR
104100
--------------------------
105101

@@ -116,4 +112,3 @@ your page. HMR works automatically with CSS (as long as you're using the
116112
CSS. That is no longer needed.
117113

118114
.. _`webpack-dev-server`: https://webpack.js.org/configuration/dev-server/
119-
.. _`it's not recommended to disable host checking`: https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck

0 commit comments

Comments
 (0)