The office web add-in is missing the necessary 'Access-Control-Allow-Origin' header on the requested resource

Currently, I am attempting to make a POST request to a REST API within the Office Outlook web add-in using AJAX calls. Despite configuring the app domains in the manifest.xml file for the target URL, I am encountering CORS issues.

The error message reads: Access to XMLHttpRequest at 'https:' from origin 'https:' has been blocked by CORS policy, indicating that the request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in the preflight response.

I have been unable to pinpoint the exact reason for this issue and what may be causing it.

Sharing below some relevant code snippets from MessageRead.js:

$.ajax({
            type: "POST",
            dataType: "json",
            url: "<target url>",
            contentType: 'application/json',
            crossDomain: true,
            headers:
            {
                'X-Database': 'aln_template',
            },
                          data: {
                //id: "1598521065618",
                id: (new Date()).getTime(),
                method: "execute",
                params: params
            },
            success: function (data1) {
     }
});

Answer №1

The Access-Control-Allow-Origin header is categorized as a response header, not a request header. It is not possible to include this specific header in your post request, which is the reason for its rejection.

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

Trouble with unproductive downtime in ReactJS and JavaScript

I'm looking for a way to detect idle time and display a dialog automatically after a certain period of inactivity. The dialog should prompt the user to click a button to keep their session active. Currently, when the user clicks the button it doesn&a ...

Handling validation errors when processing AJAX requests in Django

While getting familiar with Django and jQuery, I have successfully created a basic form in Django. Upon submitting the form, I am utilizing jQuery to send an AJAX request to the server for posting data. The process of saving the data is working as expected ...

Guide to dynamically rendering Material-UI dialogs based on certain conditions

Trying to implement a dialog box based on data returned from an Apollo hook, where I need to verify that one value matches an ID. If checker === true, the dialog should open automatically and close when the user clicks the Close button. const DialogComp ...

Retrieving Data from a JSON Object Using a Specific Key

Received a JSON response similar to the one below { "SNGS": { "$": { "xmlns": "csng", "xmlns:ns2": "http://www.w3.org/1999/xlink" }, "Defec ...

Displaying a pop-up message from the server to the client using Express.js and React.js

I have successfully created a CRUD application and now I am looking to implement a feature on the frontend to notify the user if the entered FirstName already exists. Currently, I am able to log a message using console.log(), but I want to display this mes ...

Retrieving rows from a MySQL table that contain a specified BIGINT from an array parameter

I've encountered a problem with mysql while using serverless-mysql in TypeScript. It seems like my query might be incorrect. Here is how I am constructing the query: export default async function ExcuteQuery(query: any, values: any) { try { ...

When applying json_encode to the PHP $_GET array, it returns a singular string instead of an array containing strings

I am attempting to utilize the PHP GET method in order to generate an array of keywords from a keywordBox field on a different page. For instance, here is how the keywords are added to the page URL: /searchResults.php?keywordBox=computing+finance Althou ...

A guide on switching out an HTML element with an AJAX response

How can I dynamically replace an HTML element with Ajax response? I know how to remove the element, but I'm unsure how to then insert the new content from the Ajax call. For instance, let's say I have the following code: <ul id="products"> ...

Failure to Acknowledge Asynchronous Behavior in Loop

I've hit a roadblock with an Async function. My Objective - I'm building a batchProcessing function (batchGetSubs) that will iterate through a set of files, extract an ID, make an API request, wait for a response (THE ISSUE), and then write the ...

Submit form results in success/error message constantly vanishing

My application, (editsessionadmin.php), allows users to input their assessment's name, date, and time. Upon submission, a confirmation message is displayed and, upon user acceptance, the system uses ajax to navigate to updatedatetime.php. Here, it upd ...

Handling conditional statements in JSX

Here is an example of my straightforward component: function Messages(props) { return ( <View> <View style={styles.messageWrapper} > <View style={styles.isNotMine}> <View style={s ...

Close specific child python processes as needed, triggered by a jQuery event

Having trouble managing child processes independently without affecting the main parent process in a web client using jQuery? Look no further. Here's my scenario: I've got a Flask server hosting a basic webpage with a button. Clicking the button ...

Utilize JavaScript and CSS to create dynamic text animations

(() => { const paraElement = document.querySelector('#animated-text'); const spanElement = paraElement.querySelector('span'); const wordsList = JSON.parse(spanElement.dataset.words); let counter = 0; setInterval(funct ...

Retrieve a value from a PHP database table and transfer it to a different PHP webpage

I have values retrieved from a database and I need to select a row from a table and pass those values to the next PHP page, OInfo.php. I attempted to use Javascript to place those values in textboxes, but upon clicking the continue button, the values are n ...

Naming axes in Chart.js is a simple process that can easily be implemented

Greetings to all, I'm currently working on creating bar charts using chartjs...everything is going smoothly except for one thing - I am struggling to find a clean way to name my axes without resorting to CSS tricks like absolute positioning. Take a ...

Navigate a user upon completion of an update

My webpage requires users to click an update link, which triggers a process of fetching data from an API that takes a few minutes. I don't want users to have to constantly refresh the page to know when the process is complete and they can continue. Is ...

Does React include a mechanism for event dispatching and listening?

Recently, I've been exploring the intricacies of the Laravel framework and have been fascinated by its event dispatching and listening system. In the past, I've dabbled with electron which shares similarities with Laravel's system, but in m ...

Is there a way to automatically change the display of an element once the user has closed the menu?

How can I ensure that the display of an element remains unchanged when a user opens and closes my website menu using JavaScript? ...

From traditional relational databases to MongoDB/Mongoose database design

Recently, I ventured into using mongoDB and mongoose for a new node.js application. Coming from a background of relational databases, I find it challenging to adjust to the mongoDB/noSQL approach, particularly concerning denormalization and the absence of ...

Use jQuery and AJAX to seamlessly upload images

Currently, I am attempting to utilize ajax to upload a photo. Here is the input I am working with: <input type="file" name="defaultPhoto"> Here is a snippet of my jQuery code: var form = #insertCredentials var defaultPhoto = $('#' + fo ...