Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

CSP error on rest api by plugin

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 Leader Dec 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
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

3,788 views 10 47
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you