Skip to content
This repository was archived by the owner on Dec 9, 2019. It is now read-only.

Commit 3f4f53e

Browse files
TheNodicpriego
authored andcommitted
Use UUID for static asset path instead of "static" (cpriego#132)
Brought to you by @TheNodi
1 parent 49b6737 commit 3f4f53e

File tree

7 files changed

+10
-7
lines changed

7 files changed

+10
-7
lines changed

cli/Valet/Nginx.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public function installServer()
9999
$this->files->putAsUser(
100100
$this->sites_available_conf,
101101
str_replace(
102-
['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_PORT'],
103-
[VALET_HOME_PATH, VALET_SERVER_PATH, $this->configuration->read()['port']],
102+
['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX', 'VALET_PORT'],
103+
[VALET_HOME_PATH, VALET_SERVER_PATH, VALET_STATIC_PREFIX, $this->configuration->read()['port']],
104104
$this->files->get(__DIR__.'/../stubs/valet.conf')
105105
)
106106
);

cli/Valet/Site.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ public function createSigningRequest($url, $keyPath, $csrPath, $confPath)
272272
/**
273273
* Build the SSL config for the given URL.
274274
*
275-
* @param string $url
275+
* @param string $url
276276
* @return string
277277
*/
278278
public function buildCertificateConf($path, $url)
279279
{
280-
$config = str_replace('VALET_DOMAIN', $url, $this->files->get(__DIR__.'/../stubs/openssl.conf'));
280+
$config = str_replace('VALET_DOMAIN', $url, $this->files->get(__DIR__ . '/../stubs/openssl.conf'));
281281
$this->files->putAsUser($path, $config);
282282
}
283283

@@ -323,6 +323,7 @@ public function buildSecureNginxServer($url)
323323
[
324324
'VALET_HOME_PATH' => VALET_HOME_PATH,
325325
'VALET_SERVER_PATH' => VALET_SERVER_PATH,
326+
'VALET_STATIC_PREFIX' => VALET_STATIC_PREFIX,
326327
'VALET_SITE' => $url,
327328
'VALET_CERT' => $path . '/' . $url . '.crt',
328329
'VALET_KEY' => $path . '/' . $url . '.key',

cli/drivers/ValetDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
165165
header('Content-Type: text/html');
166166
header_remove('Content-Type');
167167

168-
header('X-Accel-Redirect: /static' . $staticFilePath);
168+
header('X-Accel-Redirect: /' . VALET_STATIC_PREFIX . $staticFilePath);
169169
}
170170

171171
/**

cli/includes/helpers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
define('VALET_HOME_PATH', $_SERVER['HOME'].'/.valet');
1212
define('VALET_SERVER_PATH', realpath(__DIR__ . '/../../server.php'));
13+
define('VALET_STATIC_PREFIX', '41c270e4-5535-4daa-b23e-c269744c2f45');
1314

1415
/**
1516
* Output the given text to the console.

cli/stubs/secure.valet.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ server {
1010
root /;
1111
charset utf-8;
1212

13-
location /static/ {
13+
location /VALET_STATIC_PREFIX/ {
1414
internal;
1515
alias /;
1616
try_files $uri $uri/;

cli/stubs/valet.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ server {
44
charset utf-8;
55
client_max_body_size 128M;
66

7-
location /static/ {
7+
location /VALET_STATIC_PREFIX/ {
88
internal;
99
alias /;
1010
try_files $uri $uri/;

server.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
define('VALET_HOME_PATH', posix_getpwuid(fileowner(__FILE__))['dir'].'/.valet');
8+
define('VALET_STATIC_PREFIX', '41c270e4-5535-4daa-b23e-c269744c2f45');
89

910
/**
1011
* Show the Valet 404 "Not Found" page.

0 commit comments

Comments
 (0)