Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 Content-Type header set incorrectly. #277

Closed
JT-Bruch opened this issue Feb 1, 2022 · 3 comments · Fixed by #278
Closed

S3 Content-Type header set incorrectly. #277

JT-Bruch opened this issue Feb 1, 2022 · 3 comments · Fixed by #278
Labels
bug Something isn't working
Milestone

Comments

@JT-Bruch
Copy link

JT-Bruch commented Feb 1, 2022

When our build is generated, there is a folder structure that looks like as follows:

However, the issue is that in the S3 bucket, the upload is setting the content-type header as application/emcascript on only the es page itself which is causing the page to be rendered as text instead of a website.

image

image

this is what our next.config.js looks like

const withPlugins = require('next-compose-plugins');

module.exports = withPlugins([], {
  experimental: {
    externalDir: true,
  },
  i18n: {
    locales: ['en', 'es'],
    defaultLocale: 'en',
    localeDetection: false,
  },
  images: {
    domains: ['res.cloudinary.com'],
  },
  publicRuntimeConfig: {
    IS_DEV: process.argv.includes('dev'),
  },
  async headers() {
    return [
      {
        source: '/es',
        headers: [
          {
            key: 'Content-Type',
            value: 'text/html; charset=utf-8',
          },
        ],
      },
    ]
  },
  async rewrites() {
    return [
      {
        source: '/es',
        destination: '/es.html',
      },
    ]
  },

Solution:

I can manually go in and set the header to text/plain and then the page renders properly. Any ideas on how I can fix this?

Thanks!

@JT-Bruch
Copy link
Author

JT-Bruch commented Feb 1, 2022

If I can't get this to work, I am going to have to move our production from AWS -> Vercel, and I would rather not do that.

@ofhouse
Copy link
Member

ofhouse commented Feb 1, 2022

Hi, it looks like the mime-types package, we use internally for determining the content-type header, thinks that es is the file ending:

const mimeType = mimeLookup(fileName);
const contentType =
typeof mimeType === 'string' ? mimeContentType(mimeType) : false;

@ofhouse ofhouse added the bug Something isn't working label Feb 1, 2022
@ofhouse ofhouse added this to the Upcoming Iteration milestone Feb 1, 2022
@ofhouse
Copy link
Member

ofhouse commented Feb 1, 2022

This has now been fixed in v0.11.4, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants