Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,746
Community Members
 
Community Events
184
Community Groups

How do I use javascript in my Bitbucket Pages website?

So I've been trying to set up a website using Bitbucket Pages. I've pushed all the files to a repository I created xxxx.bitbucket.io. I can access web pages there through the browser. But I get this weird error in the chrome console if the html file loads any javascript files:

"[Report Only] Refused to load the script 'xxxx' because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'strict-dynamic' 'unsafe-inline' 'self' http: https: https://d301sr5gafysq2.cloudfront.net". 'strict-dynamic' is present, so host-based whitelisting is disabled. Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback."

I have script tags in the header of my document like so:

<script src="jquery-3.4.1.min.js"></script>
<script src="jquery.csv.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.6.1/firebase-app.js"></script>

I have looked it up and found that this is to do with CSP. So how do I sort this out? I tried adding this meta tag:

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'">

But this didn't work. I thought that if I omitted 'strict-dynamic' in the script-src directive that it would work. Is it not working because there are directives somewhere in a place that I cannot edit that clash with the ones in the meta tag? If so, how do I change these? CSP seems to be a rather complex and unintuitive topic I've tried to get my head around and I'm very confused. It seems that Bitbucket has some kind of policy in place that I cannot change. But I just need these scripts working. How do I do this?

1 answer

1 accepted

0 votes
Answer accepted
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 17, 2019

Hi @jonayoung2003welcome to the Community.

You can only publish static websites on Bitbucket Cloud, as stated at Publishing a website. Dynamic sites like the one you're trying to publish are not allowed and thus the errors you're getting.

Hope that explains. Let us know if you have any other questions.

Best regards,

Ana

Ah I see, I mistakenly thought that dynamic meant the usage of server side code like PHP etc. It says that I am allowed to use Javascript on that page. So does that mean I can only use it if it is in the html document and not loaded from some other source?

Like Marco Behringer likes this

Also, might this change at any point? It will be inconvenient and unscalable to have to copy and paste code everywhere.

Like # people like this

According to the link referenced, javascript is allowed to be included... and I've used javascript extensively on my bitbucket.io site. So I don't think that is the policy or the issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events