Forums

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

Getting MIME type while including js file into html file which calling from nodejs

Siva Mandapati August 22, 2018

server.js

var express = require('express');
var OAuth = require('oauth').OAuth;
var url = require('url');
var app = express();


const requestURL = "https://trello.com/1/OAuthGetRequestToken";
const accessURL = "https://trello.com/1/OAuthGetAccessToken";
const authorizeURL = "https://trello.com/1/OAuthAuthorizeToken";
const appName = "Trello OAuth Example";
const key = myAPIkey;
const secret = myTrelloSecret;
const loginCallback = "https://{my-host-name}/callback";
const oauth_secrets = {};

const oauth = new OAuth(requestURL, accessURL, key, secret, "1.0A", loginCallback, "HMAC-SHA1")

const login = function(request, response) {
oauth.getOAuthRequestToken(function(error, token, tokenSecret, results){
oauth_secrets[token] = tokenSecret;
response.redirect(`${authorizeURL}?oauth_token=${token}&name=${appName}`);
});
};

var callback = function(req, res) {
const query = url.parse(req.url, true).query;
const token = query.oauth_token;
const tokenSecret = oauth_secrets[token];
const verifier = query.oauth_verifier;
oauth.getOAuthAccessToken(token, tokenSecret, verifier, function(error, accessToken, accessTokenSecret, results){
trelloToken=accessToken;
trelloTokenSecret=accessTokenSecret;
res.sendFile(__dirname + '/views/index.html');
});
};

app.get('/', function(request, response) {
login(request, response);
});

app.get("/callback", function (request, response) {
callback(request, response);
});


var listener = app.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});

 

index.html

<html>
<head>
<title>A Trello Dashboard</title>
<script src="https://p.trellocdn.com/power-up.min.js"></script>
<script src="./../public/client.js"></script>
</head>
<body>
</body>
</html>

This is my code. while running this i got error like

"Refused to execute script from 'https://{my-host-name}/public/client.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."

Can anyone help to me?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events