Я могу заставить его работать на локальном хосте через:
Код: Выделить всё
fetch('/rust/hello') // Proxy through Apache (no need for port in URL)
.then(response => response.text())
.then(data => {
console.log(data); // Should log "Hello, world!"
})
.catch(error => console.error('Error:', error));
Я не могу получить AJAX вызов для работы над производством.
Я думаю, что ошибка может быть связана с пользовательской маршрутизацией, которую я настроил в .htaccess (в корневом каталоге моего приложения). и/или 000-default-le-ssl.conf в каталоге конфигурации Apache.
Мой .htaccess:
Код: Выделить всё
Require all denied
RewriteEngine On
# Exclude /rust path from being rewritten
RewriteCond %{REQUEST_URI} ^/rust
RewriteRule ^rust/(.*)$ http://localhost:8080/$1 [P,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Код: Выделить всё
ServerName mywebsite.net
ServerAlias www.mywebsite.net
RewriteEngine on
# Skip redirection for /rust path
# RewriteCond %{REQUEST_URI} !^/rust
# Redirect everything else to HTTPS
RewriteCond %{SERVER_NAME} =mywebsite.net [OR]
RewriteCond %{SERVER_NAME} =www.mywebsite.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
# Proxy configuration
ProxyRequests Off
ProxyPreserveHost On
# ProxyPass for /rust/*
# RewriteCond %{REQUEST_URI} !^/rust
# ProxyPass /rust http://localhost:8080/
# ProxyPassReverse /rust http://localhost:8080/
# ProxyPass /rust/hello http://localhost:8080/hello
# ProxyPassReverse /rust/hello http://localhost:8080/hello
DocumentRoot /var/www/html
Options -Indexes
AllowOverride All
Require all granted
# Prevent access to .env files
Require all denied
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName mywebsite.net
ServerAlias www.mywebsite.net
DocumentRoot /var/www/html
Options -Indexes
AllowOverride All
Require all granted
# SSL Configuration
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.mywebsite.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.mywebsite.net/privkey.pem
# Redirect from HTTP to HTTPS
RewriteEngine on
RewriteCond %{HTTP_HOST} =mywebsite.net [OR]
RewriteCond %{HTTP_HOST} =www.mywebsite.net
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [END,NE,R=permanent]
# Prevent access to .env files
Require all denied
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Подробнее здесь: https://stackoverflow.com/questions/791 ... in-the-ser
Мобильная версия