Response for preflight has invalid HTTP status code 401 [duplicate] - angularjs

I am working on a project that integrates WooCommerce with Ionic 3 and I am having problems with the signup and checkout functionality. I am able to read products and login from my WooCommerce site, but every time I do a post request, I am getting these errors:
{"errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid signature - provided signature does not match."}]}
How can I fix it?

Make sure you have the following code in your .htaccess file on the top. You can find this file in the root of your WordPress.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $l [R=200,L]
Also enable CORS on your browser.

Related

React app CORS error when after deployment

I developed a system with REACT and Express.
It works well in local.
When I deployed to CPanel, I got 404 error for sub routers refreshing, so I added .htaccess like this.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
</IfModule>
After I added this, I got a CORS error when I call backend API with axios.
Please help me.
UPDATE
If I add .htaccess, I got this error.
Access to XMLHttpRequest at 'https://api.lightcoin.io/api/history?user=0x1C09d124d6c03EF63B1e0C3D1Af1b2eFE628ceE8' from origin 'https://lightcoin.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
If I remove .htaccess, it works well, but when the page of sub-router is refreshed, I got 404 error.

Sonata admin missing css files

Working on a site with php 7.2, Symfony 4 and Sonata admin 3.
In dev, on my machine, everything works fine, the site itself, and the two admins (user and content).
I have put everything on the final server (unfortunately, file by file, no console with S4 ! so, no "composer:install"...).
Still on dev, the site works fine, all functionalities.
But when I try to use the admin page, I only get a non-formatted page. None of the assets (css and js) seems to work!
However the source code are identical, on localhost and the distant site...
Can anyone help me
Edit : I found where the issue comes from : it's linked to .htaccess.
The http address I use ends in /public/index.php. I use .htaccess to shorten it and when using the .htacces redirection I can't get the assets of the admin page, while it works fine without redirection.
Is there something I should change in my .htaccess code ?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php
</IfModule>

SLIM php Angularjs CORS

I'm using SLIM framework as backend and Angularjs as frontend.Normal GET and POST API's is working fine.Whenever i pass the headers in GET or POST method it is throwing 404 error.I used the .htaccess file for CORS.
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
Header add Access-Control-Allow-Origin: "*"
Header add Access-Control-Allow-Headers: "origin, x-requested-with, content-type, authorization"
Header add Access-Control-Allow-Methods: "PUT, GET, POST, DELETE, OPTIONS"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Please help me to fix this.
If you use Chrome, you can open the network tab within the Developer Tools to view the failed request. If it's related to CORS, then it will tell you why it failed.
A 404 error usually means that the endpoint cannot be found, so check carefully that the Angular code is requesting the URL that you think it should be.

ImpressPages admin page has 404 error

I have just installed ImpressPages 4_0_17 and I completed the installation process through the point of filling out the database form and submitting it. The next page gave a 404 error on the URL /ImpressPages/admin. Prior to that, the systems check page listed 3 warnings: Magic quotes Off, Apache mod_rewrite, PHP memory limit 64MB. No other info on these warnings was available on that page.
I am using the alias feature on GoDaddy for hosting, which allows me to create multiple websites in the same account. In addition, I am using a sub-domain for this install so I can test it out before replacing the original site. Because I uploaded the entire IP zip file and extracted it in the web root folder, all the IP files are now installed in the folder /ImpressPages.
After the 404 error, I altered the URL to be just /ImpressPages/. That actually loaded fine. In addition, a small dialog popped up saying that I had been automatically logged in as admin. It gave me the username, password and the email I configured for the site. It also provided the admin page URL that produces a 404 error and said I needed to go there to login in the future.
The home page at /ImpressPages/ loads and shows inline editing features. If I click the Lorem Ipsum link, /ImpressPages/index.php/lorem-ipsumy, I get a white page with the one line:
"No input file specified."
I have tried a few tweaks to the .htaccess file with no success. The latest active lines are shown below. All the other lines from the default file are commented out and I have not tried messing with them.
<IfModule mod_rewrite.c>
RewriteEngine on
# Attempt to fix SVG images, 6/4/2014
AddType image/svg+xml svg
AddType image/svg+xml svgz
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ImpressPages/index.php?%{QUERY_STRING} [L]
# Redirect www urls to non-www.
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
The changes I attempted to get admin access are in the RewriteRule. I prefixed index.php first with a slash, then with /ImpressPages/. Neither one helped. Any suggestions on how to get admin access will be greatly appreciated.
17:11 - New info:
With the /ImpressPages/ path and the following .htaccess lines enabled, I can now get the login dialog on the admin page. Once I enter the login correctly, the next URL is /ImpressPages/index.php with the white page described previously. Then reloading /ImpressPages/admin produces the same white page and the same /ImpressPages/index.php URL. So now I can login, but it doesn't help.
Options -Indexes
Options -MultiViews
Those lines are in the default .htaccess file already. I just removed the comment character to activate them.
17:45 - more progress.
I moved all the contents of the /ImpressPages/ folder up one level to web root. Then I removed /ImpressPages/ from the path for index.php in the rewrite rule. With that one change, admin login started working and I am now able to edit my site. There are still issues. For example, publishing a page does publish the changes, but then loads the typical white page with the URL /index.php/home. The URL / loads the home page correctly. Almost sounds like the URL routing is not working correctly.
It looks like ImpressPages instal decided your server doesn't support URL rewrites and has placed rewritesDisabled in config.php
Try to remove this config line.

Cakephp not loading css and js files

I seriously can't understand what is going on here. I just uploaded my web app from localhost to new domain-name on Windows IIS Server. When I try to access the web app, CSS files and images are not loaded and I get the following error:
"CssController could not be found."
I don't understand why it is doing this.
Although I've written code like this in my default.ctp:
echo $this->html->css('generic');
CSS files are placed in:
app\webroot\css
I have searched on Google and have tried everything, I even uncommented the line:
Configure::write('App.baseUrl',env('SCRIPT_NAME')); in core.php
But I still cannot get this to work. Please help me to resolve this issue.
Double check that you have all the .htaccess files in place.
Also making sure /app/webroot/ has its .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Your request is trying to get the css file from /css/ but i'm thinking you don't have the proper .htaccess files in place to route it to the webroot and not to a controller!
also check if mod_rewrite is enabled
Edit: and then I saw the IIS part, you need some IIS equivalent to mod_rewrite
In this article you find all the information required for successfully run CakePHP web applications under Microsoft IIS web server: http://bakery.cakephp.org/articles/filippo.toso/2008/01/29/cakephp-on-iis
Here is a related question about getting cake to work on IIS: CakePHP 2.2.2 not working on Windows IIS7

Resources