Wordpress + Angularjs 站点迁移问题:显示 $domain 变量而不是实际 domain/IP
Wordpress + Angularjs site migration issue: dispalys $domain variable instead of actual domain/IP
我希望在这个前所未有的奇怪时期每个人都健康安全。
虽然我对 Wordpress 和 AngularJS 的 none 经验很少,但我不得不从 "dying" 服务器迁移 Wordpress 站点。该站点之前托管在 Bitnami WordPress Stack 上,新服务器是来自 Digital Ocean Marketplace 的 pre-made Wordpress 模板(OS:Ubuntu18.04)。
一切顺利,设置了 Wordpress,设置了数据库,一切似乎都运行良好,除了一个部分:自定义模板(对于该网站至关重要)在浏览器控制台中抛出以下错误:
Firefox:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://$domain/stories-api/. (Reason: CORS request did not succeed).
Chrome:
theme.min.js:103 GET http://%24domain/stories-api/ net::ERR_NAME_NOT_RESOLVED
一开始我认为这与 CORS headers 有关,所以我打破了我所有的安全道德来修复它。没有任何效果。
然后我注意到主题使用了AngularJS,所以我进去下载了Node、npm和Gulp。我运行一个npm install
,运行gulp
,重启了Apache2,还是没有解决问题
如果有人好奇 /stories-api/ 是什么,请看这里:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$directory = "../place-stories-here/";
// $index = 0;
$arr = array();
// Open a directory, and read its contents
if (is_dir($directory)){
if ($dh = opendir($directory)){
while (($file = readdir($dh)) !== false){
// Fill the array
$obj = array('src' => $file, 'extension' => pathinfo($file, PATHINFO_EXTENSION), 'value' => true);
if($obj['extension'] !== "" && $obj['src'] !== '.DS_Store') {
array_push($arr, $obj);
};
};
closedir($dh);
};
};
// Create JSON
echo json_encode($arr, JSON_PRETTY_PRINT);
} else {
echo "request unavailable";
};
?>
我 运行 在代码存储库中搜索以查找调用 "stories-api" 的位置,我找到了 2 个使用它的文件。都在自定义主题的文件夹中:
- app.js
- theme.min.js
两者都使用AngularJS.
有没有人知道可能导致这种情况的原因并指出正确的方向?
如果您需要更多代码片段,请告诉我!
提前致谢!
好的,经过几天和多次重启后,我唯一要做的就是:
- 转到:设置 > 永久链接
- 点击保存更改
- 再次点击保存更改
现在可以了。出于某种原因,迁移时需要重新创建永久链接才能使网站正常工作。
我希望在这个前所未有的奇怪时期每个人都健康安全。
虽然我对 Wordpress 和 AngularJS 的 none 经验很少,但我不得不从 "dying" 服务器迁移 Wordpress 站点。该站点之前托管在 Bitnami WordPress Stack 上,新服务器是来自 Digital Ocean Marketplace 的 pre-made Wordpress 模板(OS:Ubuntu18.04)。
一切顺利,设置了 Wordpress,设置了数据库,一切似乎都运行良好,除了一个部分:自定义模板(对于该网站至关重要)在浏览器控制台中抛出以下错误:
Firefox:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://$domain/stories-api/. (Reason: CORS request did not succeed).
Chrome:
theme.min.js:103 GET http://%24domain/stories-api/ net::ERR_NAME_NOT_RESOLVED
一开始我认为这与 CORS headers 有关,所以我打破了我所有的安全道德来修复它。没有任何效果。
然后我注意到主题使用了AngularJS,所以我进去下载了Node、npm和Gulp。我运行一个npm install
,运行gulp
,重启了Apache2,还是没有解决问题
如果有人好奇 /stories-api/ 是什么,请看这里:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$directory = "../place-stories-here/";
// $index = 0;
$arr = array();
// Open a directory, and read its contents
if (is_dir($directory)){
if ($dh = opendir($directory)){
while (($file = readdir($dh)) !== false){
// Fill the array
$obj = array('src' => $file, 'extension' => pathinfo($file, PATHINFO_EXTENSION), 'value' => true);
if($obj['extension'] !== "" && $obj['src'] !== '.DS_Store') {
array_push($arr, $obj);
};
};
closedir($dh);
};
};
// Create JSON
echo json_encode($arr, JSON_PRETTY_PRINT);
} else {
echo "request unavailable";
};
?>
我 运行 在代码存储库中搜索以查找调用 "stories-api" 的位置,我找到了 2 个使用它的文件。都在自定义主题的文件夹中:
- app.js
- theme.min.js
两者都使用AngularJS.
有没有人知道可能导致这种情况的原因并指出正确的方向?
如果您需要更多代码片段,请告诉我!
提前致谢!
好的,经过几天和多次重启后,我唯一要做的就是:
- 转到:设置 > 永久链接
- 点击保存更改
- 再次点击保存更改
现在可以了。出于某种原因,迁移时需要重新创建永久链接才能使网站正常工作。