Skip to content

Commit d872a47

Browse files
[9.x] Update TLS configuration options (#8164)
* document TLS configuration * document vite plugin * formatting Co-authored-by: Taylor Otwell <[email protected]>
1 parent ee5d18e commit d872a47

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

vite.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,46 @@ The Laravel plugin also supports multiple entry points and advanced configuratio
131131
<a name="working-with-a-secure-development-server"></a>
132132
#### Working With A Secure Development Server
133133

134-
If your development web server is running on HTTPS, including Valet's [secure command](/docs/{{version}}/valet#securing-sites), you may run into issues connecting to the Vite development server. You may configure Vite to also run on HTTPS by adding the following to your `vite.config.js` configuration file:
134+
If your local development web server is serving your application via HTTPS, you may run into issues connecting to the Vite development server.
135+
136+
If you are using [Laravel Valet](/docs/{{version}}/valet) for local development and have run the [secure command](/docs/{{version}}/valet#securing-sites) against your application, you may configure the Vite development server to automatically use Valet's generated TLS certificates:
135137

136138
```js
139+
import { defineConfig } from 'vite';
140+
import laravel from 'laravel-vite-plugin';
141+
142+
export default defineConfig({
143+
plugins: [
144+
laravel({
145+
// ...
146+
valetTls: 'my-app.test', // [!tl add]
147+
}),
148+
],
149+
});
150+
```
151+
152+
When using another web server, you should generate a trusted certificate and manually configure Vite to use the generated certificates:
153+
154+
```js
155+
// ...
156+
import fs from 'fs'; // [tl! add]
157+
158+
const host = 'my-app.test'; // [tl! add]
159+
137160
export default defineConfig({
138161
// ...
139-
server: { // [tl! add]
140-
https: true, // [tl! add]
141-
host: 'localhost', // [tl! add]
142-
}, // [tl! add]
162+
server: { // [!tl add]
163+
host, // [!tl add]
164+
hmr: { host }, // [!tl add]
165+
https: { // [!tl add]
166+
key: fs.readFileSync(`/path/to/${host}.key`), // [!tl add]
167+
cert: fs.readFileSync(`/path/to/${host}.crt`), // [!tl add]
168+
}, // [!tl add]
169+
}, // [!tl add]
143170
});
144171
```
145172

146-
You will also need to accept the certificate warning for Vite's development server in your browser by following the "Local" link in your console when running the `npm run dev` command.
173+
If you are unable to generate a trusted certificate for your system, you may install and configure the [`@vitejs/plugin-basic-ssl` plugin](https://github.com/vitejs/vite-plugin-basic-ssl). When using untrusted certificates, you will need to accept the certificate warning for Vite's development server in your browser by following the "Local" link in your console when running the `npm run dev` command.
147174

148175
<a name="loading-your-scripts-and-styles"></a>
149176
### Loading Your Scripts And Styles

0 commit comments

Comments
 (0)