简体   繁体   English

Heroku-Symfony2-Angular-具有角度错误的应用程序-.js无法加载?

[英]Heroku - Symfony2 - Angular - app with angular errors - .js not loading?

I just finished working on an app locally on my computer. 我刚刚在计算机上本地完成了一个应用程序的工作。 It's a weird app, using a combination of Symfony2 and Angular. 这是一个奇怪的应用程序,结合使用了Symfony2和Angular。 The app works fine locally, under developer and production mode. 在开发人员和生产模式下,该应用在本地运行良好。 But when I upload to Heroku, I get a plethora of errors on the front end: 但是,当我上传到Heroku时,前端会出现很多错误:

在此处输入图片说明

I will update this original question with any new content that may be needed to help answer this question. 我将使用可能需要的任何新内容来更新此原始问题,以帮助回答该问题。 It seems maybe the scripts aren't being loaded or something? 似乎脚本未加载或什么? My .gitignore isn't holding back any folders that contain it, so it should be uploaded to heroku. 我的.gitignore没有保留任何包含它的文件夹,因此应将其上传到heroku。

Edit 编辑

I'm looking at the loaded page content of the app (hosted on Heroku) and it appears that some scripts are being loaded, and others are not. 我正在查看应用程序(在Heroku上托管)的已加载页面内容,似乎正在加载某些脚本,而其他脚本没有加载。 I can click one script in the source, and I get a blank page, and another script (that has loaded) and it loads the script (.js). 我可以单击源中的一个脚本,然后得到一个空白页,另一个脚本(已加载)又加载了脚本(.js)。

This answer might help https://stackoverflow.com/a/35665196/5734037 这个答案可能会帮助https://stackoverflow.com/a/35665196/5734037

and i think yes google maps has some issues with inheritance 而且我认为是的,谷歌地图在继承方面存在一些问题

This one's easy. 这很简单。 If you look at the responses for the requests you'll (probably) see you get the HTML for each file instead of the actual js/css file. 如果查看请求的响应,您(可能)会看到每个文件的HTML,而不是实际的js / css文件。

I'm assuming you're using html5mode too so this usually means your server (Nodejs) is not configured properly or you're missing <base href="/"> in your index. 我假设您也使用html5mode所以这通常意味着您的服务器(Nodejs)配置不正确,或者您的索引中缺少<base href="/">

The proper way to configure NodeJS for html5mode : html5mode配置html5mode的正确方法:

//Look for statics first
var oneHour = 3600 * 1000;
app.use(express.static(path.join(__dirname, '..', 'public'), {maxAge: oneHour}));
//If miss, check API routes - not mandatory of you don't have API
app.use(require('./routers/api'));
//Return the index for any other GET request
app.get('/*', function (req, res) {
    res.sendFile('index.html', {root: path.join(__dirname, '../public')});
});

The other case is you simply did not commit the js files to heroku so the file is non-existent and you're receiving the index as default. 另一种情况是您根本没有将js文件提交到heroku,因此该文件不存在,并且您将默认接收索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM