我有一个正在设置的应用程序,可使用vagrant和vs代码在Ubuntu上运行。我将其设置为本地环境以处理该项目。该项目是在后端使用php和在前端使用AngularJS构建的。它还为管理面板使用了一个子域。
因此,在Windows主机文件中,我使用了本地IP(即192.168.33.10)并将其添加到主机文件中,以mydevarea.com表示。
然后我在Windows主机文件中为admin部分添加了一行,以将192.168.33.10映射到admin.mydevarea.com。
主站点将加载在运行Ubuntu和Apache的无聊的框中显示的窗口中。但是,由于它连接到后端管理员,因此在加载主站点mydevarea.com时会显示以下错误:
jQuery.js:4 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
send @ jQuery.js:4
2jQuery.js:4 Failed to load resource: the server responded with a status of 404 (Not Found)
send @ jQuery.js:4
jQuery.js:4 Access to XMLHttpRequest at 'http://admin.mydevarea.com/userApi/site_settings' from origin 'http://mydevarea.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
send @ jQuery.js:4
angular.js:12722 TypeError: Cannot read property 'length' of undefined
at Function.grep (jQuery.js:2)
at Object.<anonymous> (app.js:223)
at Object.e [as invoke] (angular.js:4535)
at N.instance (angular.js:9380)
at I (angular.js:8497)
at g (angular.js:7929)
at angular.js:7809
at angular.js:1682
at r.$eval (angular.js:16251)
at r.$apply (angular.js:16351)
(anonymous) @ angular.js:12722
2admin.mydevarea.com/userApi/allPages:1 Failed to load resource: the server responded with a status of 404 (Not Found)
/#/index:1 Access to XMLHttpRequest at 'http://admin.mydevarea.com/userApi/allPages' from origin 'http://mydevarea.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这是我的Apache 000-default.conf文件
<VirtualHost *:80>
ServerAdmin robert@gmail.com
ServerName mydevarea.com
ServerAlias www.mydevarea.com
DocumentRoot /var/www/html/frontend
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin robert@gmail.com
ServerName admin.mydevarea.com
ServerAlias admin.mydevarea.com
DocumentRoot /var/www/html/backend
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我进入admin.mydevarea.com时,它只会显示“未找到”错误。
所以我不确定我的问题是否出在角度,Apache或我如何将Windows主机文件映射到子域上。
先谢谢您!