Error: Invalid src prop for next/img
Answered
Stripe-headed Tanager posted this in #help-forum
Stripe-headed TanagerOP
I am getting this error:
Unhandled Runtime Error
Error: Invalid src prop (https://azureportal.skillnet.net/UserFiles/assigntest/Pictures/Pic_assigntest_56206_Avatar.png) on
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
here is my next.config.js
/ @type {import('next').NextConfig} */
const nextConfig = {
//output: 'export',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'azureportal.skillnet.net',
port: '',
pathname: '/UserFiles/assigntest/Pictures/'
}
]
}
};
what am I doing wrong?
Unhandled Runtime Error
Error: Invalid src prop (https://azureportal.skillnet.net/UserFiles/assigntest/Pictures/Pic_assigntest_56206_Avatar.png) on
next/image, hostname "azureportal.skillnet.net" is not configured under images in your next.config.jsSee more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
here is my next.config.js
/ @type {import('next').NextConfig} */
const nextConfig = {
//output: 'export',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'azureportal.skillnet.net',
port: '',
pathname: '/UserFiles/assigntest/Pictures/'
}
]
}
};
what am I doing wrong?
Answered by Ray
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
hostname: "**",
},
],
},
};
export default nextConfig;26 Replies
@Stripe-headed Tanager I am getting this error:
Unhandled Runtime Error
Error: Invalid src prop (https://azureportal.skillnet.net/UserFiles/assigntest/Pictures/Pic_assigntest_56206_Avatar.png) on `next/image`, hostname "azureportal.skillnet.net" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
here is my next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
//output: 'export',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'azureportal.skillnet.net',
port: '',
pathname: '/UserFiles/assigntest/Pictures/**'
}
]
}
};
what am I doing wrong?
try
/ @type {import('next').NextConfig} */
const nextConfig = {
//output: 'export',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'azureportal.skillnet.net',
port: '',
pathname: '/UserFiles/assigntest/Pictures/**'
}
]
}
};Stripe-headed TanagerOP
I already had the ** in the pathname - it just did not come over to discord. I copied exactly what you sent to Next config and got the same error
@Stripe-headed Tanager Click to see attachment
this work for me
Stripe-headed TanagerOP
Stripe-headed TanagerOP
which version of next.js are you using?
14.1.0
do you happen to have next.config.js and next.config.mjs in the project root?
Stripe-headed TanagerOP
just next.config.js
just did npm i next and have this version now
and try this and see if it work?
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
hostname: "**",
},
],
},
};Stripe-headed TanagerOP
what does your complete next.config.js look like?
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
hostname: "**",
},
],
},
};
export default nextConfig;Answer
im using mjs, so it use esm syntax
if you are using next.config.js
module.exports = nextConfigStripe-headed TanagerOP
I copied your file and changed the name to next.config.mjg and it works - thanks for the help!
Stripe-headed TanagerOP
put the remotePatterns object back in and it works
thanks for the help
np