The website was accessed via HTTPS, but an insecure XMLHttpRequest endpoint from the same website was requested

My axios request below is going out over https, but I'm encountering a specific error:

The page at 'http://websitename/folder1/folder2/api/atlas/home/coach' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://websitename/folder1/folder2/api/user?userid=15'. This request has been blocked; the content must be served over HTTPS.

Axios request snippet

loadUser() {    
            this.memberid = this.$route.params.userid;             
            if (axios == null) {
                    return;
                }  
                axios
                .get('https://websitename/folder1/folder2/api/atlas/api/user/', {
                    params: {
                        userid: this.loggedinuser
                        }
                    })
                .then(res => {
                    this.user = res.data.user[0].name;                 
                })
                .catch(err => {
                    console.log(err);
                });
            }

While observing the network logs, I noticed that the request URL is sent over HTTPS but the Response header is showing http in the location field. How can I resolve this issue?

Answer №1

The problem was fixed by including

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
in the code

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to transfer form data in Vue to a variable in JSON format using Axios?

I am currently using the following method: let newFormData = { productName: this.productName, productModel: this.productModel, prodDescription: this.prodDescription, prodPrice: this.prodPrice, promoPrice: this ...

Ensuring state is updated once an action has been completed | React and Redux

My application relies on retrieving data from an API and operates as a CRUD application. One of the functionalities involves deleting an item from a list, and here is the corresponding action: import axios from 'axios' export function removeUse ...

WebPack Error: When calling __webpack_modules__[moduleId], a TypeError occurs, indicating that it is not a function during development. In production, an Invalid hook call error

Encountering a WebPack error when utilizing my custom library hosted as a package and streamed with NPM Link. Interestingly, the production version functions flawlessly. Below are my scripts: "scripts": { "dev": "rm -rf build ...

Differences between functions in Angular services and components: which one to use?

Our Angular application is made up of excel-like grids, with 20 components each containing a unique grid. Every component includes a save() function that handles adding, editing, and deleting items. The save() function is quite large and resides in each c ...

Guide on incorporating descriptive text for an image by utilizing a data attribute within its parent element

I'm trying to find a way to attach an alt-text attribute to an image by assigning a data attribute to its parent container. Essentially, any text I input in the data-alt attribute will be set as the alt-text for the img element. How should I format ...

The ng-view directive within AngularJS appears to be malfunctioning

I am facing an issue with my simple Angular app. I have two links that are supposed to change the URL and display the correct view within the same single page application. However, when I include the controllers' module in the main module, it stops wo ...

Navigating through layers of nested data in Vue.js and assigning values to a multi-layer JSON object can be tricky

In my Vue component childEle, there is a complex form structure stored in the data: data:{ form:{ root1:Number, root2:{ child1:[], child2:{}, child3:String }, root3:[], root4:{ child4:string, child5:[] ...

Identify the credit card as either American Express or American Express Corporate

My JavaScript code can successfully detect credit card types, but I have encountered an issue. I am unable to differentiate between American Express and American Express Corporate cards. Is there a way to distinguish them or is it impossible to identify wh ...

Where should I place the .filter method within my jQuery AJAX call?

I'm currently utilizing a "GET" request to fetch data from this API While the "GET" request works properly, I'm facing an issue where some objects don't have image thumbnails to use as my source. I want to filter these out, but I'm uns ...

Storing JSONP data in a variable: Tips and Tricks

Having an issue with storing JSONP data into variables and using it as input for a Google Pie Chart. Consider the following: Data in test.json: { "name": "ProjA", sp": 10, "current": 20 } The goal is to retrieve the SP value. Attempted solution usin ...

Modify the main element of a component

Vue.js requires only a single root element for each component, which is typically wrapped in a div tag. However, this can lead to unexpected issues, such as breaking the layout when using Bootstrap and inserting a div between specific elements like <b-r ...

What is the best way to substitute a character in a string with a specific text?

Looking to create a function that automatically replaces characters in a string with specified values. For example: let word = 'apple'; replaceValues(word); function replaceValues(value) { //Need to replace the characters 'a', &apo ...

Utilizing a switch statement for efficiently loading multiple objects within a Three.JS framework

Currently, I am working on a web 3D model viewer that utilizes Three.JS. My goal is to enable users to select different models from a dropdown list using dat.GUI. To achieve this, I have been experimenting with a switch statement, drawing inspiration from ...

Prepare for the possibility of being labeled a failure, even if you have already been labeled

I wrote a test case code using Jest to check the functionality of my application. let ticketsTransformer = new TicketTransformer(); ticketsTransformer.transform = jest.fn(() => results); expect(ticketsTransformer.transform).toHaveBeenCalled(); con ...

Which specific event in NextJS is triggered only during the initial load?

I am working on a NextJS app and I want to implement an initial loading screen that only appears during the first load. Currently, the loading screen pops up not only on the initial load but also whenever a link is clicked that directs the user back to the ...

Why Isn't the Element Replicating?

I've been working on a simple comment script that allows users to input their name and message, click submit, and have their comment displayed on the page like YouTube. My plan was to use a prebuilt HTML div and clone it for each new comment, adjustin ...

Providing Node-server with Vue.js Server Side Rendering

I've been attempting to deploy the Hackernews 2.0 demo on my Digital Ocean droplet but have hit a roadblock. npm run start starts the server on port :8080. npm run build is used for production builds. The specific build tasks can be found below: ...

The invocation of `prisma.profile.findUnique()` is invalid due to inconsistent column data. An invalid character 'u' was found at index 0, resulting in a malformed ObjectID

The project I'm working on is built using Next.js with Prisma and MongoDB integration. Below is the content of my Prisma schema file: generator client { provider = "prisma-client-js" } datasource db { provider = "mongodb" url = env("DATABA ...

Display only the labels of percentages that exceed 5% on the pie chart using Chart JS

I'm currently diving into web development along with learning Chart.js and pie charts. In my project, the pie chart I've created displays smaller percentage values that are hardly visible, resulting in a poor user experience on our website. How c ...

Declaring named exports dynamically in TypeScript using a d.ts file

I have developed a collection of VueJs components in TypeScript and I want to be able to use them globally in my Vue instance using Vue.use(library), or individually through named imports in Vue components. While everything functions correctly, I am facin ...