Woocommerce在使用localhost base_url时获得401,但在使用public ip时获得成功

问题描述 投票:2回答:1

我有用于REST API的woocommerce的wordpress,wordpress在docker上运行。对于http客户端,我在Laravel应用程序中使用Guzzle6和Oauth libs来执行请求。 laravel应用程序在nginx后面运行当我将base_url设置为localhost:port时,我得到了401响应

{
    "code":"woocommerce_rest_authentication_error",
    "message":"Invalid signature - provided signature does not match.
}

当我将base_url设置为我的public ip时,它成功了。当我在我的本地机器上开发它成功使用localhost作为base_url为什么会发生这种情况?

php laravel woocommerce guzzle woocommerce-rest-api
1个回答
1
投票

WooCommerce试图在localhost上发送一个简单的GET请求和postman,我遇到了同样的问题。我通过将WP_HOMEWP_SITEURL设置为我的本地IP地址来修复它,或者转到Admin Panel > Settings > General并用localhostWordPress Address (URL)的ip地址替换Site Address (URL),如下所示:https://wordpress.stackexchange.com/questions/180207/how-to-make-other-computer-in-local-network-see-my-theme

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.