最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Deploying angular2 web app on google cloud buckets - Stack Overflow

programmeradmin4浏览0评论

So to deploy angular2 app we simply upload all production files to a bucket just as described here. (deploy static website).

But how can we redirect all urls to index.html so that angular2 router can take care of them. We can set Main Page from website configuration of bucket. But we cannot specify that all urls should redirect to index.html.

Currently any url other than Main Page results in 404 page not found.

There is similar question on SO for amazon S3, but cannot find one for google cloud.

So to deploy angular2 app we simply upload all production files to a bucket just as described here. (deploy static website).

But how can we redirect all urls to index.html so that angular2 router can take care of them. We can set Main Page from website configuration of bucket. But we cannot specify that all urls should redirect to index.html.

Currently any url other than Main Page results in 404 page not found.

There is similar question on SO for amazon S3, but cannot find one for google cloud.

Share Improve this question edited May 23, 2017 at 12:02 CommunityBot 11 silver badge asked Jun 27, 2016 at 11:44 hhsadiqhhsadiq 2,9531 gold badge27 silver badges41 bronze badges 8
  • Maybe you should share your current app configuration? – Dan Cornilescu Commented Jun 27, 2016 at 13:05
  • 1 configuration of angular2 app..?? – hhsadiq Commented Jun 27, 2016 at 13:37
  • 1 this is uploaded to simple google cloud bucket. Like uploading angular2 production folder from google buckets UI, there is no configuration for google app engine involved. – hhsadiq Commented Jun 27, 2016 at 13:41
  • Ah, I was thrown off by the google-app-engine tag :) – Dan Cornilescu Commented Jun 27, 2016 at 16:33
  • 1 @Nag: I haven't tried. hhsadiq's answer looks good. – Dan Cornilescu Commented Nov 24, 2016 at 14:22
 |  Show 3 more ments

1 Answer 1

Reset to default 8

I solved this issue by using a hack, not sure what the proper way to do this. But atleast this worked.

  1. Open storage in console.cloud.google..

  2. Click edit website configuration in buckets listing. Click far right in row with three dots. And select edit configuratione

  3. Enter your main page same as 404 page. The angular routing will work fine this way.

发布评论

评论列表(0)

  1. 暂无评论