Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CSP error on rest api by plugin

Riccardo Atzeni
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 27, 2021

Hi,
I'm developing a Custom UI plugin through Forge for Confluence Cloud.

When I attempt to make some rest call from plugin to Confluence I get:
 Refused to connect to 'https://<environment>.atlassian.net/wiki/rest/api/template/page' because it violates the following Content Security Policy directive: "connect-src 'self'".


Do you have any idea of what problem could be?

 

project_structure.PNG


App.js

import React, { Component } from 'react';
//import { invoke } from '@forge/bridge';
import {ExcelRenderer} from 'react-excel-renderer';
import axios from 'axios';

class App extends Component {

  constructor(props) {
    super(props);
    this.state = { cols: null, rows: null };
  }

  /*useEffect(() => {
    invoke('getText', { example: 'my-invoke-variable' }).then(setData);
  }, []);*/

  componentDidMount() {

    console.log(' COMPONENT DID MOUNT START');

              { headers: { Authorization: 'Basic <API TOKEN ENCODED BASE 64>',
                           Accept:  'application/json',
                           'Content-Security-Policy': 'script-src skyoffermanagement.atlassian.net'} })
    .then(response => {
      console.log(
        `Response: ${response.status} ${response.statusText}`
      );
      console.log(response.text());
    })
    .catch(err => console.error(err));

  }

  fileHandler = (event) => {
    let fileObj = event.target.files[0];

    ExcelRenderer(fileObj, (err, resp) => {
      if(err)console.log(err);            
   
      else{
        console.log('ExcelRender response: ', resp);

        for( let i=1; i < resp.rows.length; i++){
   
        }

      }
    });            
  }

  render(){
    return (
      <div>
        <input type="file" onChange={this.fileHandler.bind(this)} style={{"padding":"10px"}} />
      </div>
    );
  }

}

export default App;


manifest.yml

modules:
  macro:
    - key: excel-proposal
      resource: main
      resolver:
        function: resolver
      title: excel-proposal
      description: Component to upload excel proposal
  function:
    - key: resolver
      handler: index.handler
resources:
  - key: main
    path: static/fe/build
app:
  id: ari:cloud:ecosystem::app/cd8b9860-3f91-4012-89a7-b6b8d20e37c3
permissions:
  scopes:
    - 'read:confluence-content.summary'
  content:
    scripts:
    - 'unsafe-inline'  

1 answer

0 votes
Fabian Lim
Community Champion
December 27, 2021

Hi @Riccardo Atzeni

Welcome to the community.  I recommend you also post this question in the dev community for a faster response. 

Good Luck

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events