Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
Hosting an angular 2 app on s3, unable to display local images

I'm hosting an angular 2 app on s3. I'm using redirect rules on the s3 bucket, as defined in the answer.

<RoutingRules>
  <RoutingRule>
    <Condition>
      <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
    </Condition>
    <Redirect>
      <HostName>yourdomainname.com</HostName>
      <ReplaceKeyPrefixWith>#!/</ReplaceKeyPrefixWith>
    </Redirect>
  </RoutingRule>
</RoutingRules>

My angular app is then using html5 routing to match the redirect rules:

In app.module.ts:

RouterModule.forRoot(appRoutes, { useHash: true })

This combination works well, with the exception of displaying an image in the assets folder of the website. This is in my navbar:

<img src="./assets/logo.png" id="group-ed-logo" />

I am using the angular-cli, which has the following in the angular-cli.json:

"assets": [
        "assets",
        "assets/logo.png",
        "favicon.ico",
        "logo.png"
      ],

Edit: I have added logo.png to the above and put the logo.png file at the root directory of the src file and then used:

<img src="logo.png" id="group-ed-logo" />

The logo then displays. It would be tidier to have the images in an assets folder. However, it may be that the angular-cli currently doesn't support assets in folders when using html 5 routing.

If the file is in the assets directory, then I am getting a 404 url not found: "http://www.myurl.com/#/assets/logo.png".

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

For folders, in the bucket 'Create a folder' then add your files to that bucket.

Also, if you drag and dropped the whole dist folder, you may be looking at the inside of the dist folder on the AWS UI, not realizing that you are in the dist folder. Copy only the contents of the dist folder, not the dist folder. -- This happened to me.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda