Axios adds extra slash on get request - node.js

Axios adds extra slash on get request after the domain name, https://DOMAIN_NAME//api/get, but only when accessing via the domain name, not via local IP. When accessing via ip, it works fine.
I have tried remove the slash from on the server side, but it still has double slash. I have also tried turning off caching but no success.
If you have any ideas, please write then in an answer.

Related

Wildcard requiring trailing slash in Azure API Management (APIM)

In Azure API Management (APIM), I want to setup wildcards for all GET and POST operations to my backend service. I'm encountering an issue where the consumer has to specify a trailing slash in order for the request to complete.
The wildcard is specified in APIM like this:
Example, these all work:
{{endpoint}}/devices/ <-- notice trailing slash here)
{{endpoint}}/devices/12345
{{endpoint}}/devices/12345/foo
It's just the base endpoint of a resource that does not work without the trailing slash, like:
{{endpoint}}/devices
In my particular case, it doesn't seem to recognise the route without the explicit trailing slash and requires the user to authenticate.
Is there a way to accept both with/without trailing slashes?
solved it as follow :
set up a GET /{*path} wildcard operation for current api
add the following policy to the operation inbound processing:
<rewrite-uri template="{path}" copy-unmatched-params="true" />
screenshots in github post

IIS URL Rewrite - A potentially dangerous Request.Path value was detected from the client (:)

My client is trying to access the URL with triple slash (:///), however, the error occurred as shown in the title. They do not want any modification to the URL, so is there any way for the triple slash to be accepted?
I do not have much information regarding it, but they tried few solutions they found from the web in modifying some parts in IIS config but it still doesn't work.

Route issue in Node JS with express

I have a godaddy domain being redirected to an instance of EC2 with an elastic IP. on instance there runs my NodeJS on port 5000. i m redirecting 80 to 5000( till here everything works fine). In express i have a route say '/Calculate/:Type', which is visited when some caculate button is pressed. ideally the when button is pressed a request to server should go like http://example.com/calculate/3 but here is goes http://example.com//calculate/3 an extra / before caculate ruins the entire route. can someone please tell me why is it happening?
Modify the route where you define the findone query and remove the forward slash from it.
Try adding a period in front of /Calculate/:Type so
'./Calculate/:Type' in your express route
Ahh so it seems like you may be hitting a CORS error. Is your webserver and dataserver on the same url?
Best option : Put the node instance serving your app on yourdomain.com, and make your api endpoint api.yourdomain.com/Calculate/:Type
Other Option: exposing yourself to security risks by adding a 'Access-Control-Allow-Origin = *' in the header of your response
Other Option: expose yourself to security change your settings in htaccess to allow all, or the specific domain

How to prefix all requests with ~username?

I'm testing moving my site to a new Linux server using cPanel which requires you to put in your IP and username (e.g. http://123.xxx.xxx.xxx/~username/). The problem is, all my image/JS/CSS links use paths like /css/style.css or /images/picture.jpg so none of the styles, scripts or images show up properly.
How do I set up a RewriteRule to prefix ~username to all requests?
Before moving site, if it was working with only domain name and with redirection then now it should also work with server IP and username, Make sure the permissions and ownership of /css/style.css or /images/picture.jpg are correct.
Also check it once adding exact path manually like 'http://123.xxx.xxx.xxx/~username/css/style.css'.
I was able to get around the issue by setting the domain to a dedicated IP instead of shared, so I could access the site using 123.xxx.xxx.xxx instead of 123.xxx.xxx.xxx/~username.

htaccess - Fetch static content from different path if page is HTTPS

As per the guidelines to speed up site, I have off-loaded all my static content (JS|CSS|IMAGES) to a subdomain static.example.com.
The site is working fine but the problem arises when I load the secure pages. Browser throws a warnings for "InsecureContent" being loaded into my page.
We have ssl for only root domain not subdomain. I can't get another one but want to handle it this way. As the subdomain folder can be accessed inside the root folder i want this.
I want to handle this with .htaccess this way ->
When referer is https ://www.example.com/anything.php
Rewrite http ://static.example.com/folder/file.ex to https ://www.example.com/static/folder/file.ex
Somebody help me doing this.
Not going to help at all. In order for anything inside an htaccess file to get processed, the request has to have been received by the webserver. When your browser pops up the "Insecure Content" warning, it hasn't sent the request yet. This warning pops up when negotiating the SSL connection, and in your case, your cert doesn't cover the domain the request is being made to. That means adding any sort of redirect on the server's end isn't going to help. You're still going to see the warning.
You need to ensure that your content points to http://static.example.com/ somehow, by either using a relative URI base or maybe absolute URLs that explicitly point to http://.
Another option may be to use some kind of javascript on the client side.

Resources