• Hi there,

    I have a WP Mulitsite Installation, working with subdomains. I have a woocommerce installation on the main site (https://myshopdomain.de) and a wordpress installation on a multsite (https://XXX.myshopdomain.de)

    In an angular app I fetch orders via

    getWooCommerceOrders(uri, username, password, afterDate, page = 1): Observable<HttpResponse<Object>> {
        var options = {
          'method': 'GET',
          'url': uri+'/wp-json/wc/v3/orders?after=' + afterDate + '&per_page=100&page='+page+'&status=on-hold,processing',
          'headers': {
            'Authorization': <code>Basic ${window.btoa(username + ':' + password)}</code>
          }
        };
    
        return this.http.get<Array<any>>(
          options.url, {
          headers: options.headers, observe: 'response'
        });
      }

    On the main site via https://myshopdomain.de it is working, on the multisite via https://XXX.myshopdomain.de I get the following error message calling the API (status 401). Please note that I’m 100% sure that the CS + CK is correct!

    HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "https://XXX.myshopdomain.de/wp-json/wc/v3/orders?aft…:33&per_page=100&page=1&status=on-hold,processing", ok: false, …}
    error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: "error", …}
    headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)}
    message: "Http failure response for https://XXX.myshopdomain.de/wp-json/wc/v3/orders?after=2020-07-12T23:46:33&per_page=100&page=1&status=on-hold,processing: 0 Unknown Error"
    name: "HttpErrorResponse"
    ok: false
    status: 0
    statusText: "Unknown Error"
    url: "https://XXX.myshopdomain.de/wp-json/wc/v3/orders?after=2020-07-12T23:46:33&per_page=100&page=1&status=on-hold,processing"
    __proto__: HttpResponseBase

    Calling the following API via Angular App or Postman, it works:
    https://XXX.myshopdomain.de/wp-json/wc/v3/orders?after=2020-07-12T23:46:33&per_page=100&page=1&status=on-hold,processing&consumer_key=ck_XXXX2312&consumer_secret=cs_XXXXXf9f1

    I guess there is a problem with my .htaccess, am I right? Could someone guide my to a solution, please?

    my .htaccess:

    # BEGIN iThemes Security - Diese Zeile nicht verändern oder entfernen
    # iThemes Security Config Details: 2
    	# Pass through Authorization header.
    	<IfModule mod_rewrite.c>
    		RewriteEngine On
    		RewriteCond %{HTTP:Authorization} ^(.*)
    		RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
    	</IfModule>
    
    	# Hosts dauerhaft aussperren - Sicherheit > Einstellungen > Dauerhafte Benutzeraussperrung
    	SetEnvIF REMOTE_ADDR "^111\.229\.246\.143$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^111\.229\.246\.143$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^111\.229\.246\.143$" DenyAccess
    
    	SetEnvIF REMOTE_ADDR "^198\.245\.49\.57$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^198\.245\.49\.57$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^198\.245\.49\.57$" DenyAccess
    
    	SetEnvIF REMOTE_ADDR "^62\.210\.215\.49$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^62\.210\.215\.49$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^62\.210\.215\.49$" DenyAccess
    
    	SetEnvIF REMOTE_ADDR "^198\.100\.145\.155$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^198\.100\.145\.155$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^198\.100\.145\.155$" DenyAccess
    
    	SetEnvIF REMOTE_ADDR "^62\.210\.84\.2$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^62\.210\.84\.2$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^62\.210\.84\.2$" DenyAccess
    
    	SetEnvIF REMOTE_ADDR "^62\.210\.177\.248$" DenyAccess
    	SetEnvIF X-FORWARDED-FOR "^62\.210\.177\.248$" DenyAccess
    	SetEnvIF X-CLUSTER-CLIENT-IP "^62\.210\.177\.248$" DenyAccess
    
    	<IfModule mod_authz_core.c>
    		<RequireAll>
    			Require all granted
    			Require not env DenyAccess
    			Require not ip 111.229.246.143
    			Require not ip 198.245.49.57
    			Require not ip 62.210.215.49
    			Require not ip 198.100.145.155
    			Require not ip 62.210.84.2
    			Require not ip 62.210.177.248
    		</RequireAll>
    	</IfModule>
    	<IfModule !mod_authz_core.c>
    		Order allow,deny
    		Allow from all
    		Deny from env=DenyAccess
    		Deny from 111.229.246.143
    		Deny from 198.245.49.57
    		Deny from 62.210.215.49
    		Deny from 198.100.145.155
    		Deny from 62.210.84.2
    		Deny from 62.210.177.248
    	</IfModule>
    
    	# XML-RPC deaktivieren - Sicherheit > Einstellungen > WordPress-Optimierungen > XML-RPC
    	<files xmlrpc.php>
    		<IfModule mod_authz_core.c>
    			Require all denied
    		</IfModule>
    		<IfModule !mod_authz_core.c>
    			Order allow,deny
    			Deny from all
    		</IfModule>
    	</files>
    # END iThemes Security - Diese Zeile nicht verändern oder entfernen
    
    # BEGIN WordPress
    # Die Anweisungen (Zeilen) zwischen „BEGIN WordPress“ und „END WordPress“ sind
    # dynamisch generiert und sollten nur über WordPress-Filter geändert werden.
    # Alle Änderungen an den Anweisungen zwischen diesen Markierungen werden überschrieben.
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    
    # END WordPress
    
    <IfModule mod_deflate.c> 
    # Komprimiere HTML, CSS, JavaScript, Text, XML und fonts
      AddOutputFilterByType DEFLATE application/javascript
      AddOutputFilterByType DEFLATE application/rss+xml
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
      AddOutputFilterByType DEFLATE application/x-font
      AddOutputFilterByType DEFLATE application/x-font-opentype
      AddOutputFilterByType DEFLATE application/x-font-otf
      AddOutputFilterByType DEFLATE application/x-font-truetype
      AddOutputFilterByType DEFLATE application/x-font-ttf
      AddOutputFilterByType DEFLATE application/x-javascript
      AddOutputFilterByType DEFLATE application/xhtml+xml
      AddOutputFilterByType DEFLATE application/xml
      AddOutputFilterByType DEFLATE font/opentype
      AddOutputFilterByType DEFLATE font/otf
      AddOutputFilterByType DEFLATE font/ttf	
      AddOutputFilterByType DEFLATE image/svg+xml
      AddOutputFilterByType DEFLATE image/x-icon
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/html
      AddOutputFilterByType DEFLATE text/javascript
      AddOutputFilterByType DEFLATE text/plain
      AddOutputFilterByType DEFLATE text/xml
    
      # Browser bugs entfernen (nur für wirklich alte Browser)
      BrowserMatch ^Mozilla/4 gzip-only-text/html
      BrowserMatch ^Mozilla/4\.0[678] no-gzip
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
      Header append Vary User-Agent
    </IfModule>
    
    • This topic was modified 5 years, 2 months ago by pierrebrezel.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Mulisite Installation – WooCommerce API 401 code’ is closed to new replies.